The initial GREPLAY procedure step in the first part of the code sample is used for housekeeping purposes. That is, it deletes the previous GRSEG entries in the WORK directory so that graph entries begin with NAME#1. The ODS DOCUMENT statements are used to store the tables and graphics output into an item store named NESTED.
The second part of this code sample uses the MAKE, DIR, SETLABEL, COPY, and REPLAY statements. These statements maintain three tables and a graph in the body of the PDF file. In addition, they also simplify the table of contents into one that contains only two parent nodes, each of which has two child nodes. This code generates a more readable table of contents, shown as AFTER.PDF in the Results tab.
It is important to note that this logic can also be used with the HTML and RTF destinations using the CONTENTS= option on the ODS HTML statement, and the CONTENTS and TOC_DATA options on the ODS RTF statement. For example:
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
/* Part 1 */
proc greplay nofs igout=work.gseg;
delete _all_;
run;
quit;
title;
footnote;
options orientation=landscape;
/* ODS PDF FILE= is used here to demonstrate the default */
/* table of contents structure. It is unnecessary for */
/* use with the ODS DOCUMENT statements. */
ods listing close;
ods document name=nested;
ods pdf file="before.pdf";
proc sql;
select * from sashelp.cars;
run;
quit;
ods select parameterestimates;
proc reg data=sashelp.cars ;
model mpg_highway=mpg_city;
run;
quit;
proc gchart data=sashelp.class;
vbar age / sumvar=height;
run;
quit;
proc freq data=sashelp.class;
tables age;
run;
ods pdf close;
ods document close;
/* Part 2 */
/* The MAKE statement creates a directory called FIRST. */
/* The DIR statement is used three times. It sets paths */
/* to both first#1 and second#2. The second DIR statement */
/* is used to move back up the TOC tree, so that subsequent */
/* COPY statements are child nodes under second#2 instead of */
/* under first#1. The SETLABEL statements are use in order */
/* to name/label the nodes. */
/* ODS LISTING is turned on in order for the LIST statements */
/* to be directed to the OUTPUT window. It is turned off */
/* before the item store's output is replayed to the PDF */
/* destination. */
ods listing;
proc document name=nested;
list / levels=all; run;
make first;
dir \first#1;
setlabel \first#1 "Parent A";
setlabel \SQL#1\SQL_Results#1 "Child 1A";
setlabel \Reg#1\MODEL1#1\Fit#1\MPG_Highway#1\ParameterEstimates#1 "Child 2A";
copy \SQL#1\SQL_Results#1 to ^; run;
copy \Reg#1\MODEL1#1\Fit#1\MPG_Highway#1\ParameterEstimates#1 to ^;
dir ^^;
run;
make second; run;
dir \second#1; run;
setlabel \second#1 'Parent B' ; run;
setlabel \Gchart#1\Gchart#1 "Child 1B";
setlabel \Freq#1\Table1#1\OneWayFreqs#1 "Child 2B";
copy \Gchart#1\Gchart#1 to ^;
copy \Freq#1\Table1#1\OneWayFreqs#1 to ^; run;
dir ^^;run;
list / levels=all;
run;
ods listing close;
ods pdf file="after.pdf";
replay \first#1, \second#1;
run;
ods pdf close;
quit;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
Type: | Sample |
Date Modified: | 2011-04-04 13:52:22 |
Date Created: | 2011-03-24 08:22:21 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | Base SAS | Windows Vista | 9.2 TS1M0 | |
Windows Vista for x64 | 9.2 TS1M0 | |||
64-bit Enabled AIX | 9.2 TS1M0 | |||
Microsoft Windows XP Professional | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |||
Microsoft® Windows® for x64 | 9.2 TS1M0 | |||
Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |||
z/OS | 9.2 TS1M0 | |||
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |||
64-bit Enabled HP-UX | 9.2 TS1M0 | |||
64-bit Enabled Solaris | 9.2 TS1M0 | |||
HP-UX IPF | 9.2 TS1M0 | |||
Linux | 9.2 TS1M0 | |||
Linux for x64 | 9.2 TS1M0 | |||
OpenVMS on HP Integrity | 9.2 TS1M0 | |||
Solaris for x64 | 9.2 TS1M0 |