The DOCUMENT Procedure

Example 3: Navigating the Directory and Listing the Entries

Features:

ODS DOCUMENT statement option: NAME=

DOC statement option: NAME=

LIST statement options:
entry
LEVELS=
DETAILS

DIR statement option : path

Procedure output: PROC DOCUMENT

ODS destinations: DOCUMENT

LISTING

Details

This example shows you how to do these tasks:
  • name an ODS document
  • see what ODS documents exist
  • open a document for browsing or editing purposes
  • list one or more entries
  • change directories

Program

options nodate nonumber;
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;   
ods document name=univ;
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;
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;
ods document close;
title;
proc document;
   doc;
   doc name=univ;
   list/levels=all; 
   dir \Univariate#2\Exponential_x#1\Histogram#1\Exponential#1;
   list;
   list fitquantiles/details;
run;
     
quit;

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;
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. Assign a libref to create Univ 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 the DOCUMENT destination is not closed, no DOCUMENT procedure output can be viewed.
ods document close;
title;
View the ODS documents, choose an ODS document, and list the entries of the opened ODS document. The DOC statement (with no arguments specified) prints a listing of all of the available documents that are in the SAS system. The DOC statement with the NAME= option specifies the current document, Work.Univ. The LIST statement with the LEVELS=ALL option lists detailed information about all levels of the document Work.Univ.
proc document;
   doc;
   doc name=univ;
   list/levels=all; 
Set the current directory to EXPONENTIAL, list the contents of the EXPONENTIAL directory, select a table, and list the details of the table that you selected. The DIR statement changes the current directory to \Univariate#2\Exponential_x#1\Histogram#1\Exponential#1. The path \Univariate#2\Exponential_x#1\Histogram#1\Exponential#1 was obtained from the listing of the Work.Univ document .The LIST statement (with no arguments) lists the contents of EXPONENTIAL. The LIST FITQUANTILES\DETAILS statement specifies that ODS opens the FitQuantiles table and lists its details.
   dir \Univariate#2\Exponential_x#1\Histogram#1\Exponential#1;
   list;
   list fitquantiles/details;
run;
     
Terminate the DOCUMENT procedure. Specify the QUIT statement to terminate the DOCUMENT procedure. If you omit QUIT, then you will not be able to view DOCUMENT procedure output.
quit;

Output

Current ODS Document in Output
Current ODS Document in Output
List of the Entries of the ODS Document Work.Univ and the Properties of Those Entries
List of the Entries of the ODS Document Work.Univ and the Properties of Those Entries
List of the Entries of the Exponential#1 Entry and the Properties of Those Entries
List of the Entries of the Exponential#1 Entry and the Properties of Those Entries
Details of the FitQuantiles#1 Table
Details of the FitQuantiles#1 Table