It is sometimes desired to create a customized table of contents page that provides links to subsequent pages in a PDF file. The CONTENTS option in the ODS PDF statement generates a table of contents as the first PDF page. However, it requires the table of contents (TOC) tree to be in effect.
This sample shows how to generate a table of contents page using ODS TEXT= statements. The URL style attribute is used to make this table of contents a navigation page to tables and graphs on later pages in the PDF file. This table of contents also includes links from subsequent pages back to the contents page. The default table of contents is suppressed with the NOTOC option.
The sample code on the Full Code tab illustrates this using the following logic:
Please find additional information for further customizing this sample below:
Anchor values must be lower case prior to the third maintenance release of SAS® 9.2 (TS2M3). See SAS Note 37323 for additional information. Anchor values must also conform to rules discussed in SAS Note 32888.
If a change to the borders surrounding the URL links is desired, see SAS Note 24182.
For similar logic to create a customized table of contents using CALL DEFINE logic with the REPORT procedure, see SAS Note 24459.
The ODS PDF statement is documented in the SAS Online Documentation.
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.
ods escapechar="^";
ods listing close;
options orientation=portrait nodate nonumber;
title;
footnote;
ods pdf file="sample.pdf" notoc ;
/* Generate a customized 'table of contents' page. */
/* Note: ODS PDF TEXT= statements are necessary prior to SAS 9.2. */
ods text="^{style [just=c] Customized table of contents }";
ods text="^{newline 5}";
ods text="^{style [just=c URL='#table1'] Report output }";
ods text="^{style [just=c URL='#graph1'] Graph output }";
/* Create an anchor to the invisible PROC REPORT table. */
ods pdf anchor="contents";
proc report nowd data=sashelp.class(obs=1) noheader
style(report)={rules=none frame=void cellpadding=0}
style(column)={foreground=white};
run;
/* Force a page break with the STARTPAGE=NOW option. */
ods pdf startpage=now;
/* Turn off pagination so that the TEXT= and procedure */
/* output is combined on the same page. */
ods pdf startpage=no;
/* Create an anchor to the PROC REPORT table. */
ods pdf anchor="table1";
proc report data=sashelp.cars nowd;
where cylinders le 6;
col origin cylinders mpg_city mpg_highway;
define origin / group;
define cylinders / group;
define mpg_city / mean;
define mpg_highway / mean;
run;
/* Create a link back to the 'table of contents' page. */
ods text="^{style [just=c URL='#contents']Back to p. 1 }";
ods pdf startpage=now;
ods pdf startpage=no;
/* Create an anchor to the PROC GCHART graph. */
ods pdf anchor="graph1";
goptions vsize=4in hsize=4in;
proc gchart data=sashelp.cars;
vbar origin;
run;
quit;
/* Create a link back to the 'table of contents' page. */
ods text="^{style [just=c URL='#contents']Back to p. 1 }";
ods _all_ close;
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: | 2012-02-17 15:34:00 |
Date Created: | 2012-02-10 16:10:26 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | Base SAS | z/OS | 9.2 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |||
Microsoft® Windows® for x64 | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |||
Microsoft Windows XP Professional | 9.2 TS1M0 | |||
Windows Vista | 9.2 TS1M0 | |||
Windows Vista for x64 | 9.2 TS1M0 | |||
64-bit Enabled AIX | 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 |