Sample 24602: Creating a table of contents for PDF and RTF output with the DATA step
Create a table of contents (TOC) for multiple output written to the same PDF or RTF destination.
Note:
In Microsoft Word, you can create a table of contents (TOC) using several methods. SAS 9.1 directly supports one of these methods. ODS RTF can embed, or hide, TOC data in the file. In ODS RTF, when you open a file with the command:
ods rtf file="test.rtf" contents;
A first page is generated that has the title on it but is otherwise empty. The TOC information is embedded in the file. To create the TOC, 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, which causes Word to scan the document and build a TOC on that page, below the title. If more ODS RTF output is later appended, you can update the TOC 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 listing destination for efficiency */
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 DETAILS tab for important info */
/* In SAS 9.2 use:
ods rtf file='c:\temp\contents.rtf' contents toc_data;
See this SASnote for additional information:
http://support.sas.com/kb/32/747.html
*/
/* Override the default label 'The Datastep Procedure' in TOC */
ods proclabel "Ms. Crabapple's Class";
title 'Class Health Information';
data _null_;
file print ods; /* Use 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 listing */
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 (TOC) for multiple output written to the same 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 |