Examples: DOCUMENT Procedure


Example 1: Navigating the File Location and Listing the Entries

Procedure features:

  • ODS DOCUMENT statement options:

    • NAME =

  • DOC statement option:

      • NAME=

  • LIST statement options:

      • entry

      • LEVELS=

      • DETAILS

  • DIR statement option:

    • path

ODS Destinations:

  • DOCUMENT

  • LISTING

  • HTML

Procedure output:

  • PROC DOCUMENT

This example shows you how to do the following:

  • name an ODS document

  • see what ODS documents exist

  • open a document for browsing or editing purposes

  • list one or more entries

  • change file locations.

Program

Set the SAS system options. The NODATE option suppresses the display of the date and time in the output. The NONUMBER option suppresses the printing of page numbers .

 options nodate nonumber; 

Create the DISTRDATA data set. The DISTRDATA data set contains the statistical information that PROC UNIVARIATE uses to create the histograms.

 data distrdata;    drop n;    label Normal_x='Normal Random Variable'          Exponential_x='Exponential Random Variable';    do n=1 to 100;       Normal_x=10*rannor(53124)+50;       Exponential_x=ranexp(18746363);       output;    end;  run; 

Create the ODS document UNIV and open the DOCUMENT destination. The ODS DOCUMENT statement opens the document destination. The NAME= option assigns the name UNIV to the ODS document that contains the information from this PROC UNIVARIATE program.Note that by default UNIV will be created in the WORK library. You must assign a libref if you want UNIV to be created in a permanent library.

 ods document name=univ; 

Create a normal distribution histogram. The TITLE statement specifies the title of the normal distribution histogram. The PROC UNIVARIATE step creates a normal distribution histogram from the DISTRDATA data set.

 title '100 Obs Sampled from a Normal Distribution';  proc univariate data=distrdata noprint;    var Normal_x;    histogram Normal_x /normal(noprint) cbarline=grey name="normal";  run; 

Create an exponential distribution histogram. The TITLE statement specifies the title of the exponential histogram. The PROC UNIVARIATE step creates an exponential distribution histogram from the DISTRDATA data set.

 title '100 Obs Sampled from an Exponential Distribution';  proc univariate data=distrdata noprint;    var Exponential_x;    histogram /exp(fill l=3) cfill=yellow midpoints=.05 to 5.55 by .25               name="exp";  run; 

Close the DOCUMENT destination. If you do not close the DOCUMENT destination, you will be unable to see DOCUMENT procedure output.

 ods document close;  title; 

View your documents, choose a document, and list the entries of the document you open. The DOC statement (with no arguments specified) prints a listing of all of the available documents that are in the SAS System (see ).

The DOC statement with the NAME= option specifies the current document, WORK.UNIV. The LIST statement with the LEVELS=ALL option lists detailed information on all levels of the document WORK.UNIV (see ).

 proc document;     doc;     doc name=univ;     list/levels=all; 

Set the path to EXPONENTIAL, list the contents of the EXPONENTIAL file location, select a table, and list the details of the table you selected. The DIR statement changes your current file location to

univariate#2\exponential_x\fitteddistributions\exponential . The path univariate#2\exponential_x\fitteddistributions\exponential was obtained from the listing of the WORK.UNIV document (see Display 1.6).

The LIST statement (with no arguments) lists the contents of EXPONENTIAL (see List of the EXPONENTIAL#1 Entry). The LIST fitquantiles/details statement specifies that ODS opens the FitQuantiles table and lists its details (see Details of the FitQuantiles#1 Table).

 dir univariate#2\exponential_x\fitteddistributions\exponential;     list;     list fitquantiles/details;     run; 

Terminate the DOCUMENT procedure. You must specify the QUIT statement to terminate the DOCUMENT procedure. If you do not specify QUIT, then you will not be able to view DOCUMENT procedure output.

 quit; 
Output

The following display shows that there are currently two ODS documents, SASUSER.ODSGLM and WORK.UNIV.

click to expand
Display 6.6: List of ODS Documents

The following display shows the entries of the ODS document WORK.UNIV and the properties of those entries.

click to expand
Display 6.7: List of the Contents of WORK.UNIV

The following display shows a list of entries of the EXPONENTIAL#1 entry and the properties of those entries.

click to expand
Display 6.8: List of the EXPONENTIAL#1 Entry

The following display is a list of the details of the FitQuantiles table.

click to expand
Display 6.9: Details of the FitQuantiles#1 Table

Example 2: Opening and Listing ODS Documents

Procedure features:

  • PROC DOCUMENT statement option:

    • NAME=

  • DIR statement

  • LIST statement option:

    • DETAILS

    • LEVELS

  • REPLAY statement

ODS Destinations:

  • DOCUMENT

  • LISTING

  • PDF

Procedure output:

  • PROC DOCUMENT

  • PROC UNIVARIATE

DATA SET: DISTRDATA on page 245

This example shows you how to do these tasks :

  • open an ODS document

  • replay a table and send the output to the LISTING and PDF destinations

  • list the entries in an ODS document

  • change file locations

  • list the details of a specified entry

  • replay an ODS document to a PDF file.

Program

Set the SAS system options. The NODATE option suppresses the display of the date and time in the output. The NONUMBER option suppresses the printing of page numbers.

 options nodate nonumber; 

Open the ODS document WORK.UNIV. The PROC DOCUMENT statement with the NAME= option specified, opens the ODS document WORK.UNIV for updates.

 proc document name=univ; 

Specify that you want to replay your output to a PDF file. The ODS PDF statement opens the PRINTER destination and replays the histogram to the PDF destination. The FILE= statement sends all output objects to the external file that you specify.

 ods pdf file= "  your_file  .pdf"; 

List the entries that are associated with the current document and replay a histogram. The LIST statement with the LEVELS=ALL option specified, lists detailed information on all levels of the current document WORK.UNIV (see Display 6.7 on page 247). The REPLAY statement replays the NORMAL#1 entry to all open ODS destinations (see Display 6.11 on page 251).

 list/levels=all;  replay univariate#1\Normal_x#1\Normal#1; 

View the file EXPONENTIAL, list the details of the FitQuantiles table, and replay the FitQuantiles table. The DIR statement changes the current file location to univariate#2\exponential_x\fitteddistributions\exponential#1 . The LIST statement (with no arguments) lists the entries in the EXPONENTIAL file location (see Display 6.12 on page 251).

The LIST statement with the DETAILS option specifies the listing of the properties of the entry FitQuantiles table (see ).

The REPLAY statement replays FITQUANTILES to the PDF destination.

 dir univariate#2\exponential_x\fitteddistributions\exponential#1;     list;     list fitquantiles/details;     replay fitquantiles;  run; 

Terminate the DOCUMENT procedure and close the PDF destination. You must specify the QUIT statement to terminate the DOCUMENT procedure. If you do not specify QUIT, then you will not be able to view DOCUMENT procedure output. The ODS PDF CLOSE statement closes the PDF destination and all the files that are associated with it. If you do not close the destination, then you will not be able to view the files.

 quit;  ods pdf close; 
Output

The following display shows the contents of WORK.UNIV.

click to expand
Display 6.10: List of the Contents of WORK.UNIV
click to expand
Display 6.11: Replayed Normal Distribution Histogram
click to expand
Display 6.12: List of the EXPONENTIAL#1 File Location

The following display shows the properties of the FitQuantiles#1 table, viewed in the SAS Output window.

click to expand
Display 6.13: Details of the FitQuantiles#1 Table

The following display shows the replayed FitQuantiles#1 table that was sent to the LISTING destination.

click to expand
Display 6.14: Replayed FitQuantiles#1 Table

The following display is page 1 of the ODS document WORK.UNIV that was sent to the PDF destination. You can browse the output by clicking the entries.

click to expand
Display 6.15: ODS Document WORK.UNIV, Viewed in Acrobat Reader

Example 3: Managing Entries

Procedure features:

  • PROC DOCUMENT statement option:

    • NAME=

  • DIR statement

  • LIST statement option:

    • LEVELS=

  • NOTE statement

  • OBANOTE statement

  • OBBNOTE statement

  • OBFOOTN statement

  • OBPAGE statement

  • OBSTITLE statement

  • OBTITLE statement

  • REPLAY statement

ODS Destinations:

  • DOCUMENT

  • HTML

  • LISTING

Procedure output:

  • PROC CONTENTS

This example shows you how to do these tasks:

  • generate PROC CONTENTS output to the DOCUMENT destination

  • change the title and footnote of the output

  • add a before-note and an after-note to the output

  • change the subtitle of the output

  • add a note to the document

  • add a page break to the output.

Program

Set the SAS system options. The NODATE option suppresses the display of the date and time in the output. The PAGENO= option specifies the starting page number.

 options nodate pageno=1; 

Close the LISTING destination and open the DOCUMENT destination. The NAME= option creates an ODS document named CLASS .

 ods listing close;  ods document name=class; 

Specify a global title and footnote. The TITLE statement creates a title that is used until you change it with another statement. The FOOTNOTE statement creates a footnote that is used until you change it with another statement. For information about the global FOOTNOTE and TITLE statements, see SAS Language Reference: Dictionary .

 title 'Title Specified with the Global TITLE Statement';  footnote 'Footnote Specified with the Global FOOTNOTE Statement'; 

View the contents of the SAS data set. The CONTENTS procedure shows the contents of a SAS data set sashelp.class .

 proc contents data=sashelp.class;  run; 

Close the DOCUMENT destination. The entries in the ODS document CLASS are used in the remainder of this example.

 ods document close; 

Create LISTING and HTML output. The ODS LISTING statement opens the LISTING destination and creates listing output.

The ODS HTML statement opens the HTML destination and creates HTML 4.0 output. The STYLE= option specifies that ODS use the style definition D3D.

 ods listing;  ods html file='  your_file.html  ' style=d3d; 

Change the global title. The OBTITLE statement assigns a new title to the Attributes#1 object. See Title, Subtitle, and Before-note on page 257.

  • The NAME= option specifies the current ODS document.

  • The LIST statement with the LEVELS=ALL option shows a list of entries in the CLASS document. Note that PROC DOCUMENT is still running after the RUN statement executes.

  • The DIR statement changes the current path to \Contents#1\DataSet#1.

  • REPLAY generates output for all open ODS destinations.

  • The QUIT statement terminates PROC DOCUMENT.

 proc document name=class;     list /levels=all;  run;     dir \Contents#1\DataSet#1;  run;     obtitle Attributes#1 'Title Specified with the OBTITLE Statement';     replay;  run;  quit; 

Add a before-note to the output. The OBBNOTE statement assigns a before-note to the Attributes#1 object. See Title, Subtitle, and Before-note on page 257.

  • The NAME= option specifies the current ODS document.

  • The DIR statement changes the current file location to \Contents#1\DataSet#1.

  • The REPLAY statement generates output for all open ODS destinations.

  • The QUIT statement terminates PROC DOCUMENT.

 proc document name=class;     dir \Contents#1\DataSet#1;  run;     obbnote Attributes#1 'Add Before Note using the OBBNOTE Statement';     replay;  run;  quit; 

Change the global footnote. The OBFOOTN statement assigns a new footnote to the object Variables#1 .

  • The NAME= option specifies the current ODS document.

  • The DIR statement changes the current file location to \Contents#1\DataSet#1.

  • The REPLAY statement generates output for all open ODS destinations.

  • The QUIT statement terminates PROC DOCUMENT.

 proc document name=class;     dir \Contents#1\DataSet#1;  run;     obfootn Variables#1 'Change Footnote using the OBFOOTN Statement';     replay;  run;  quit; 

Add an after-note. The OBANOTE statement assigns an after-note to the Attributes#1 object. See Display 6.18 on page 258.

  • The NAME= option specifies the current ODS document.

  • The DIR statement changes the current file location to \Contents#1\DataSet#1.

  • The REPLAY statement generates output for all open ODS destinations.

  • The QUIT statement terminates PROC DOCUMENT.

 proc document name=class;     dir \Contents#1\DataSet#1;  run;     obanote Attributes#1 'After Note Specified by the OBANOTE Statement';     replay;  run;  quit; 

Change the subtitle of the output. The OBSTITLE statement changes the subtitle. The subtitle identifies the procedure that produced the output. See Title, Subtitle, and Before-note on page 257.

  • The NAME= option specifies the current ODS document.

  • The DIR statement changes the current file location to \Contents#1\DataSet#1.

  • The REPLAY statement generates output for all open ODS destinations.

  • The QUIT statement terminates PROC DOCUMENT.

 proc document name=class;     dir \Contents#1\DataSet#1;  run;     obstitle Attributes#1 'Subtitle Specified with the OBSTITLE Statement';     replay;  run;  quit; 

Add a note to the document. The NOTE statement adds a note object named ADDNOTE to the ODS document. See Note Is Added and Footnote Is Changed on page 258.

  • The NAME= option specifies the current ODS document.

  • The LIST statement with the LEVELS=ALL option shows a list of entries in the CLASS document.

  • The QUIT statement terminates PROC DOCUMENT.

 proc document name=class;     note addnote 'Note added to the document';     list /levels=all;   run;   quit; 

Add a page break to the output. The OBPAGE statement inserts a page break.

  • The NAME= option specifies the current ODS document.

  • The REPLAY statement generates output for all open ODS destinations.

  • The QUIT statement terminates PROC DOCUMENT.

 proc document name=class;     obpage \Contents#1\DataSet#1\Variables#1;     replay;  run;  quit; 

Close the HTML and LISTING destinations. The ODS _ALL_ CLOSE statement closes all open ODS output destinations so that you can view the output.

 ods _all_ close; 
Output
click to expand
Display 6.16: Global Title and Footnote
click to expand
Display 6.17: Title, Subtitle, and Before-note
click to expand
Display 6.18: After-note Is Specified by the OBANOTE Statement
click to expand
Display 6.19: Note Is Added



SAS 9.1 Output Delivery System. Users Guide
SAS 9.1 Output Delivery System Users Guide
ISBN: 1590472187
EAN: 2147483647
Year: 2004
Pages: 99
Authors: SAS Institute

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net