Sample 24602: Create a table of contents for ODS PDF and RTF output with the DATA step
The sample code on the Full Code tab illustrates how to create a table of contents for multiple outputs written to the same ODS PDF or RTF destination.
Note: In Microsoft Word, you can create a table of contents using several methods. SAS® 9.1 directly supports one of these methods. ODS RTF can embed, or hide, table of contents data in the file. In ODS RTF, when you create a file with the TOC_DATA command, a first page is generated that contains the title, but it is otherwise empty:
ods rtf file="test.rtf" contents toc_data;
The table of contents information is embedded in the file. To create the table of contents, you must update an RTF instruction field. With your cursor in the body of the page, select your right mouse button to display a pop-up menu. Select Update Field from the menu. This causes Word to scan the document and build a table of contents on that page, below the title. If more ODS RTF output is appended later, you can update the table of contents in the same manner.
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.
/* Close the Listing destination */
ods listing close;
/* CONTENTS option is alias for CONTENTS=YES */
ods pdf file='c:\temp\contents.pdf' contents=yes;
ods rtf file='c:\temp\contents.rtf' contents; /* See the Details tab for important information */
/* In SAS 9.2 use the following:
ods rtf file='c:\temp\contents.rtf' contents toc_data;
See this SAS Note for additional information:
http://support.sas.com/kb/32/747.html
*/
/* Override the default label 'The Datastep Procedure' in the table of contents */
ods proclabel "Ms. Crabapple's Class";
title 'Class Health Information';
data _null_;
file print ods; /* Use the default table template */
set sashelp.class;
put _ods_;
run;
ods proclabel "Teacher - Crabapple";
title 'Class Roster - Girls';
data _null_;
file print ods=(variable=(name
age));
set sashelp.class (keep=name sex age);
where sex='F';
put _ods_;
run;
ods proclabel "Teacher - Crabapple";
title 'Class Roster - Boys';
data _null_;
file print ods=(variable=(name
age));
set sashelp.class (keep=name sex age);
where sex='M';
put _ods_;
run;
ods _all_ close;
ods listing; /* Reopen the Listing 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.
Create a table of contents for multiple outputs written to the same ODS PDF or RTF destination.
Type: | Sample |
Topic: | Query and Reporting ==> Creating Reports ==> Non Graphical SAS Reference ==> ODS (Output Delivery System) SAS Reference ==> DATA Step
|
Date Modified: | 2005-12-08 11:34:09 |
Date Created: | 2004-09-30 14:08:57 |
Operating System and Release Information
SAS System | Base SAS | Tru64 UNIX | 9.1 TS1M0 | n/a |
OpenVMS Alpha | 9.1 TS1M0 | n/a |
HP-UX IPF | 9.1 TS1M0 | n/a |
Linux | 9.1 TS1M0 | n/a |
64-bit Enabled Solaris | 9.1 TS1M0 | n/a |
64-bit Enabled HP-UX | 9.1 TS1M0 | n/a |
64-bit Enabled AIX | 9.1 TS1M0 | n/a |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M0 | n/a |
z/OS | 9.1 TS1M0 | n/a |