Sample 38051: Dynamically create a single node in the Table of Contents or the bookmark list for each procedure using ODS
Dynamically creating a single node in the Table of Contents regardless of the procedure executed can be accomplished by using PROC DOCUMENT. The DOCUMENT procedure can be used to completely modify the Table of Contents across all procedures. With the combination of the ODS Document facility and macro code, we can modify the Table of Contents dynamically without having to control each object manually.
The macro listed in the Full Code tab keeps only the first node from each procedure in the Table of Contents without having to know the directory structure. In the example code, a new directory is created using the MAKE statement, and only the object is copied to the new folder and replayed using PROC DOCUMENT within the ODS destination.
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.
This sample illustrates how to dynamically create a single node in the Table of Contents or the bookmark list for each procedure using ODS.
/* Create sample ODS Document from three procedures */
ods document name=temp(write);
proc shewhart data=sashelp.class;
cchart age*name;
run;
quit;
proc sql;
select * from sashelp.class;
run;
quit;
proc tabulate data=sashelp.class;
class age sex;
var height;
table age*sex height;
run;
ods document close;
/* Create data set from all levels */
ods output properties=temp;
proc document name=temp;
list / levels=all;
run;
quit;
/* Create a unique macro variable for each object */
data _null_;
set temp end=last;
if type in("Table","Report","Graph") then do;
count+1;
call symput('path'||trim(left(count)),path);
end;
if last then call symput('total',count);
run;
/* Loop through each macro variable and copy the output */
/* object to a new folder and then replay it. */
%macro test;
ods pdf file="temp.pdf";
proc document name=temp;
make \ newfolder;
setlabel \ newfolder "Procedure Output";
%do i=1 %to &total;
%let proc=%substr(%scan(&&path&i,1,"#"),2);
setlabel &&path&i "&proc procedure";
copy &&path&i to \ newfolder#1;
%end;
replay \newfolder;
run;
quit;
ods pdf close;
%mend;
%test
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.
This sample illustrates how to dynamically create a single node in the Table of Contents or the bookmark list for each procedure using ODS.
Date Modified: | 2010-02-03 13:53:19 |
Date Created: | 2009-12-06 18:34:22 |
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.1 TS1M3 SP4 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows XP 64-bit Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Advanced Server | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Datacenter Server | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Server | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Professional | 9.1 TS1M3 SP4 | |
Microsoft Windows NT Workstation | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows XP Professional | 9.1 TS1M3 SP4 | |
Windows Vista | 9.1 TS1M3 SP4 | |
64-bit Enabled AIX | 9.1 TS1M3 SP4 | |
64-bit Enabled HP-UX | 9.1 TS1M3 SP4 | |
64-bit Enabled Solaris | 9.1 TS1M3 SP4 | |
HP-UX IPF | 9.1 TS1M3 SP4 | |
Linux | 9.1 TS1M3 SP4 | |
Linux on Itanium | 9.1 TS1M3 SP4 | |
OpenVMS Alpha | 9.1 TS1M3 SP4 | |
Solaris for x64 | 9.1 TS1M3 SP4 | |
Tru64 UNIX | 9.1 TS1M3 SP4 | |