By Dr. Karl Ho, Research and Statistical Support Services Manager
What's new in SAS 8.2? - Publishing in Portable Document Format*
Portable Document Format (PDF) is one of the most popular publishing formats on the Web. The benefits are many. You can post a PDF file on a site and let others download it and read it in the free Adobe Acrobat reader. Since the files are platform-independent, they are portable to and readable in any machines. Another advantage of the PDF files is printer-readiness and the files are not subject to any corruption or post-production editing. All content, formats, and fonts are retained in the file. Creating PDF files used to require Adobe Distiller. Until SAS 8.2.
The newest version of SAS is equipped with two methods to generate SAS output in PDF files. Its new device drivers can directly export graphs into a separate PDF file. On top of that, the Output Delivery System (ODS) is enhanced with more features that format and manage the output into PDF files. This method allows more control on the formatting and other aspects in a PDF file such as author information, bookmarks, etc. Let's start by examining the PDF output using the direct export method and ODS.
I. Native Device Driver: PDF and PDFC
This method is simple and very easy to apply. Just specifies the device driver DEVICE=PDF (or PDFC) in the GOPTIONS statement before running the PROC GCHART procedure, just as follows:
GOPTIONS RESET=ALL DEVICE=PDFC GSFNAME=output GSFMODE=REPLACE;
/* Graphics procedure goes here */
The FILENAME statement specifies the location and name of the output file. The DEVICE= option in the GOPTIONS statement specifies a color PDF named pie.pdf be created. The following is the original SAS graph.
II. Using ODS
ODS allows more control over the format and subsidiary information of the PDF output file, including:
The general syntax for ODS PDF setup is:
ODS PDF FILE="filename.pdf";
The following program modified from a SAS sample program generates a multi-page report mixed with SAS output and charts:
data sample; length Season Region $12.; do Season='Spring','Summer','Fall','Winter'; do Region='North','East','South','Central','West'; Sales=ceil(ranuni(0)*10); output; end; end; run; /***Using the ODS PDF destination to create output ***/ options orientation=landscape; goptions reset=all ftext="Times"; pattern1 value=solid color=cx994477; pattern2 value=solid color=cx997744; pattern3 value=solid color=cx449977; pattern4 value=solid color=cx447799; pattern5 value=solid color=cx774499; ods pdf file='c:\temp\multpage.pdf' AUTHOR="Karl Ho" KEYWORDS="Vbar, PROC FREQ, PRINT, PDF" SUBJECT="Sample PDF output" TITLE="Sales report" STARTPAGE=on; ods listing close; ods proclabel="Sales Volume"; title1 "Sales Data"; proc print; run; ods proclabel="Sales by Region"; title1 "Sales by Region"; proc freq; run; ods proclabel="Sales Charts"; title1 'Summer and Winter Sales'; proc gchart data=sample; where season in('Summer' 'Winter'); vbar3d region / sumvar=sales discrete group=season patternid=midpoint cframe=cxe0e0e0 description="Summer and Winter" midpoints="North" "East" "Central" "West" "South"; run;quit; ods proclabel="Sales Charts"; title1 'Spring and Fall Sales'; proc gchart data=sample; where season in('Spring' 'Fall'); vbar3d region / sumvar=sales discrete group=season patternid=midpoint cframe=cxe0e0e0 description="Spring and Fall" midpoints="North" "East" "Central" "West" "South"; run;quit; ods pdf close; ods listing; Click here to view the output.
The beauty of the new PDF output method is its simplicity. It is extremely easy to use and add on to an existing program. One can create a sample program and change the output location and filename for every new report. It is ideal for Web publishing since the PDF file is platform- and browser-independent, i.e. regardless Netscape or Microsoft Internet Explorer, as long as the Adobe Acrobat Reader or plug-in is installed. And it is free, no additional proprietary software is needed. A caveat is the PDF output method is primarily designed for SAS graphics. It does not work in all text output procedures (e.g. PROC REPORT). For some of these procedures, some fine-tuning may be needed in order output can be ported into the PDF file. So far, I've encountered no problem in generating output using most procedures. Again, your mileage may vary. Good luck PDFing.
* Sample program and materials are extracted from the SAS Technical Report TS-659 (http://ftp.sas.com/techsup/download/technote/ts659/ts659.html)