Usage Note 35375: How to append to a PDF file created by ODS
It is not currently possible to append to a PDF file that was created by ODS from within SAS®. However, this sample illustrates two methods that enable you to combine multiple tables in a PDF file using SAS.
The first code sample (Method 1) on the Full Code tab shows how to use multiple PDF instances to route to more than one PDF file at a time. This results in four files: COMBINED.PDF contains three PROC REPORT tables, while A.PDF, B.PDF, and C.PDF each contain the results from single PROC REPORT steps. Documentation showing how to open multiple PDF instances is available here.
The second code sample (Method 2) on the Full Code tab shows how to use ODS DOCUMENT to save each PROC REPORT table's output into separate document item stores in a permanent SAS library. The PROC DOCUMENT syntax shows how those REPORT tables can be replayed into a single PDF file using the REPLAY statement. Reference and links to the SAS online documentation discussing the ODS DOCUMENT and PROC DOCUMENT are available
here.
These examples might prevent the need for appending to PDF files outside of SAS.
Operating System and Release Information
SAS System | Base SAS | Microsoft Windows 2000 Professional | 9.1 TS1M0 | |
Microsoft Windows 2000 Server | 9.1 TS1M0 | |
Microsoft Windows 2000 Datacenter Server | 9.1 TS1M0 | |
Microsoft Windows 2000 Advanced Server | 9.1 TS1M0 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M0 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M0 | |
z/OS | 9.1 TS1M0 | |
Microsoft Windows NT Workstation | 9.1 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M0 | |
Microsoft Windows XP Professional | 9.1 TS1M0 | |
64-bit Enabled AIX | 9.1 TS1M0 | |
64-bit Enabled HP-UX | 9.1 TS1M0 | |
64-bit Enabled Solaris | 9.1 TS1M0 | |
HP-UX IPF | 9.1 TS1M0 | |
Linux | 9.1 TS1M0 | |
OpenVMS Alpha | 9.1 TS1M0 | |
Tru64 UNIX | 9.1 TS1M0 | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
The sample code below illustrates two methods of generating a PDF file with three PROC REPORT tables. Method 1 uses multiple PDF instances to route to more than one PDF file at a time. This results in four files: COMBINED_1.PDF contains three PROC REPORT tables, while A.PDF, B.PDF, and C.PDF each contain the results from single PROC REPORT steps. Method 2 uses ODS DOCUMENT to store the REPORT tables, and then uses PROC DOCUMENT to replay the three tables to one PDF file, COMBINED_2.PDF.
/* Method 1 */
/* Turn off the Output window */
ods listing close;
/* Open two ODS PDF instances, one creating COMBINED_1.PDF, and the other creating A.PDF */
ods pdf file="combined_1.pdf";
ods pdf(a) file="a.pdf";
proc report nowd data=sashelp.class(obs=10);
title "In COMBINED.pdf and A.pdf";
run;
/* Close A.PDF, but COMBINED.PDF remains open */
ods pdf(a) close;
ods pdf(b) file="b.pdf";
proc report nowd data=sashelp.vtable(obs=20);
title "In COMBINED.pdf and B.pdf";
column libname memname nobs nvar crdate;
run;
ods pdf(b) close;
ods pdf(c) file="c.pdf" ;
proc report nowd data=sashelp.class;
title "In COMBINED.pdf and C.pdf";
run;
ods pdf(c) close;
ods pdf close;
/* You can also use this shortcut to close all ODS destinations: */
/* ods _all_ close; */
/* Method 2 */
/* Alternate method using ODS and PROC DOCUMENT */
/* Close all open destinations */
ods _all_ close;
/* Use a LIBNAME statement or directory appropriate for your SAS session */
libname docs "c:\temp";
/* Route the PROC REPORT table to a document item store named FIRST in the DOCS library */
ods document name=docs.first;
proc report nowd data=sashelp.class(obs=10);
title "first";
run;
/* Close the document itemstore */
ods document close;
/* Create a new document item store in which to save the second PROC REPORT table.
This ODS DOCUMENT NAME= / ODS DOCUMENT CLOSE logic can be included in
the original SAS session or a separate SAS session. */
ods document name=docs.second;
proc report nowd data=sashelp.vtable(obs=20);
title "Second";
column libname memname nobs nvar crdate;
run;
ods document close;
ods document name=docs.third;
proc report nowd data=sashelp.class;
title "Third";
run;
ods document close;
/* In the same SAS session or a new SAS session, combine the results
of the three document item stores with PROC DOCUMENT. */
libname docs "c:\temp";
ods pdf file="combined_2.pdf";
proc document name=docs.first;
replay;
run;
quit;
proc document name=docs.second;
replay;
run;
quit;
proc document name=docs.third;
replay;
run;
quit;
ods pdf close;
It is currently not possible to append to a PDF file created by ODS from within SAS®. However, this sample illustrates two methods that enable you to combine multiple tables in a PDF file using SAS.
Date Modified: | 2012-10-26 10:21:11 |
Date Created: | 2009-03-31 09:38:44 |