The DOCUMENT Procedure

Example 4: Opening and Listing ODS Documents

Features:

PROC DOCUMENT statement option: NAME=

DIR statement

LIST statement options:
DETAILS
LEVELS=
where-expression

REPLAY statement

Procedure output: :
PROC DOCUMENT
PROC UNIVARIATE
Data set: DistrData
ODS destinations: DOCUMENT

LISTING

PDF

Note: See Creating the Univ ODS Document for the SAS code that creates the Univ ODS document.

Details

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 specific entries in an ODS document by using WHERE expressions
  • list the details of a specified entry
  • replay an ODS document to a PDF file

Program

options nodate nonumber;
proc document name=univ; 
ods pdf file='your_file.pdf';
    list ^ (where=(_type_ = 'Graph' or _type_ = 'Table') ) / levels=all;
    replay univariate#1\Normal_x#1\Histogram#1\Histogram#1;
list \Work.Univ\Univariate#2\Exponential_x#1\Histogram#1\Exponential#1\FitQuantiles#1
/details;
replay \Work.Univ\Univariate#2\Exponential_x#1\Histogram#1\Exponential#1\FitQuantiles#1;
run;
quit;
ods pdf close;

Program Description

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. WORK.Univ was created in the example “Navigating the directory and Listing the Entries”.
proc document name=univ; 
Specify that you want to replay the 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. HTML output will be created by default.
ods pdf file='your_file.pdf';
List the entries that are associated with the current document and replay a histogram.By using a WHERE expression, the LIST statement lists only entries that are graphs or tables. The LEVELS=ALL option specifies that detailed information about all levels be shown. The ^ symbol represents the current directory. The REPLAY statement replays the Histogram#1 entry to all open ODS destinations.
    list ^ (where=(_type_ = 'Graph' or _type_ = 'Table') ) / levels=all;
    replay univariate#1\Normal_x#1\Histogram#1\Histogram#1;
List the details of the FitQuantiles table, and replay the FitQuantiles table.The LIST statement with the DETAILS option specifies the listing of the properties of the entry FitQuantiles table. The REPLAY statement replays FITQUANTILES to open destinations.
list \Work.Univ\Univariate#2\Exponential_x#1\Histogram#1\Exponential#1\FitQuantiles#1
/details;
replay \Work.Univ\Univariate#2\Exponential_x#1\Histogram#1\Exponential#1\FitQuantiles#1;
run;
Terminate the DOCUMENT procedure and close the PDF destination. Specify the QUIT statement to terminate the DOCUMENT procedure. If you omit 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

This 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 bookmarks.
List of the Graphs and Tables Found in Work.Univ, Viewed in Acrobat Reader
List of the Graphs and Tables Found in Work.Univ, Viewed in Acrobat Reader
Replayed Normal Distribution Histogram
Replayed Normal Distribution Histogram
Details of the FitQuantiles#1 Table
Details of the FitQuantiles#1 Table
Replayed FitQuantiles#1 Table
Replayed FitQuantiles#1 Table