Page One

Campus Computing News

Update on SmartForce CBT

Lab-of-the-Month: SCS

FrontPage and Dreamweaver

WebDAV and You

Your First ColdFusion Application

Today's Cartoon

RSS Matters

SAS Corner

The Network Connection

Link of the Month


Short Courses

IRC News

Staff Activities

Subscribe to Benchmarks Online
Research and Statistical Support

SAS Corner

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:

  • FILENAME output "path:pie.pdf";
    /* 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.

    Pie Chart: SUM of Sales by Region

    Check out the PDF output: Black and White | Color .  Download the free Adobe reader at it is not available at your machine   Other charts in PDF files:

    Contour plot
    3-D Block
    Bar chart

    II. Using ODS

    ODS allows more control over the format and subsidiary information of the PDF output file, including:

    • author's name

    • title

    • keywords

    • orientation (landscape or portrait)

    • fonts

    • margins

    • bookmarks

    The general syntax for ODS PDF setup is:

    ODS PDF FILE="filename.pdf";
    /* Procedures go here */

    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';
    /***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"
    SUBJECT="Sample PDF output"
    TITLE="Sales report"
    ods listing close;
    ods proclabel="Sales Volume";
    title1 "Sales Data";
    proc print;
    ods proclabel="Sales by Region";
    title1 "Sales by Region";
    proc freq; 
    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";
    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";
    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  (