Creating Adobe PDF Files From Sas Graph Output: Patrick M. Mcgown, FSD Data Services, Inc., Winston-Salem, NC
Creating Adobe PDF Files From Sas Graph Output: Patrick M. Mcgown, FSD Data Services, Inc., Winston-Salem, NC
Introduction
As more companies and individuals move online, the
demand for reporting information electronically will
continue to increase. The need to provide information
electronically is confounded by the variety of hardware
and software platforms in use. This variability in systems
can result in files being reformatted for a particular device
or resolution, preventing a standard presentation of the
information to the audience. Adobe Portable Document
Format (Pdf) provides a method for ensuring standard
presentation of information across the different hardware
and software used by the end users. This paper
discusses the different methods for creating Adobe Pdf
files from SAS Graph output. For this paper, all files and
graphs were created on a Windows NT 4.0 system with
Adobe Acrobat and Reader 4.0 installed.
PDF files, what are they good for? If you have several single page Graphs to process, this
can take some time to do and for large scale processing,
Pdf files are used with increasing frequency for on-line it is not an efficient process.
forms, documents, manuals and reports. They can be
found in many places including the SAS Online Creating Multi-Page PDF Files
Documentation and IRS Tax forms and publications. The
Adobe Portable Document Format provides a platform for Creating a single Pdf file from multiple SAS Graphs
ensuring the standard presentation of information across requires a different process. This method may also be
different hardware and software systems. Once created, used if the job requires numerous single page files,
the Pdf file retains all of the fonts, graphics, colors and making the above method too time consuming. This
formatting regardless of the platform. By downloading requires the graphs to be saved as Postscript files and
and installing the free Adobe Acrobat Reader, most then translated into Pdf files using the Adobe Distiller.
anyone can open Pdf files. The Adobe Acrobat Reader is The following program creates two graphs from
available for systems such as Windows, Macintosh, Linux, SASHELP.RETAIL with the output being saved to a
Solaris, Unix, IBM AIX, OS2, Sun SPARCstation and the Postscript file named Sample2.ps. The filename
recently released version for Palm OS 3.1 or higher. The statement assigns a Graphics Stream File destination for
ability to provide individual users with the same file the output and the GACCESS option directs the output to
regardless of their system saves time and money and the postscript file. GSFNAME may be substituted for
greatly simplifies the publishing process. GACCESS. The GSF file will contain the SAS Graphs
exported in the format specified by the device listed in the
goptions statement. In this case, the graphs are being
Creating Pdfs using SAS Version 6 exported using the 300 DPI Postscript Driver. In order to
export multiple graphs to a single file, GSFMODE must be
Version 6 does not include any Pdf drivers, requiring a
set to APPEND.
multi-step process for generating Pdf files from SAS
Graph output. Both of the processes discussed here filename gsasfile ’d:\projects\ssu2001_pdf\Sample2.ps’;
require the installation of Adobe Acrobat, software used to goptions device=ps300 gaccess=gsasfile gsfmode=append;
generate Pdf files from other systems. Once installed, proc gchart data=sashelp.retail;
Adobe Acrobat provides two methods for placing SAS title ’Sample Graph’;
Graphs into Pdf files, the Adobe PDFWriter print driver hbar sales;
and the Adobe Acrobat Distiller. vbar sales;
run;
quit;
Creating Single Page PDF files
Once the graphs have been export to the Postscript file,
For creating single page file from a single SAS Graph, the
Adobe Distiller can be used to translate the Postscript into
process includes running the graph, selecting File/Print
a multi-page Pdf file like the one below.
from the SAS menu bar, then selecting the Adobe
PDFWriter under the printer name list, and providing a
path and filename when prompted.
filename gsasfile ’d:\projects\ssu2001_pdf\sample3.pdf’;
goptions gaccess=gsasfile dev=pdf ;
proc gchart data=sashelp.retail;
title ’Sample Graph’;
hbar sales;
run;
quit;
%macro graphs(filename);
filename gsasfile "d:\projects\ssu2001_pdf\&filename..ps"; Creating Multi-Page PDF Files
goptions dev=ps300 gaccess=gsasfile gsfmode=append;
proc gchart data=sashelp.retail; The method for creating a multi-page Pdf from more than
title "&filename"; one SAS Graph is the same with one exception.
hbar sales;
vbar sales; filename gsasfile ’d:\projects\ssu2001_pdf\sample4.pdf’;
run; goptions reset=all gaccess=gsasfile dev=pdf target=ps300
quit; gsfmode=append ;
%mend; proc gchart data=sashelp.retail;
%graphs(sample2a); title ’Sample Graph’;
%graphs(sample2b); hbar sales;
%graphs(sample2c); vbar sales;
run;
Once this program is run and the postscript files created, quit;
the Adobe Distiller can be set to watch the folder and it
will process all postscript files within the folder. The In this situation, a target device must be specified and it
advantage to this is that hundreds or thousands of must contain a value other than Pdf. In the above
postscript files can be created and the Adobe Distiller can example, the target device is the 300 DPI Postscript
translate them to Pdfs during off hours. driver. If the target device is not specified or the target
device is set to Pdf, an error will occur when viewing the
Creating Pdfs using SAS Version 7 second page and it will appear blank. Using the above
code to create a two page Pdf file from the two graphs
Version 7 of SAS introduces the PDF and PDFC (color) with the device target set to PS300 results in the following
device drivers for creating Pdf output directly from SAS. Pdf file. This method works when the graphs are
Instead of specifying the postscript driver for the device, produced under the same SAS Graph procedure.
specify either of the two PDF drivers to create the file or
files.
data temp;
length text $100 function color style $8;
retain xsys ysys ’3’;
%label(50,95,’Test of Annotate Output’,black,0,0,2,swiss,5);
%label(50,85,’Page 1’,black,0,0,1.5,swiss,5);
run;
proc gslide anno=temp;
run;
quit;
Likewise, running two different SAS Graph Procedures
Below is the result of this program. and exporting the results to the same Graphics Stream
File produces the same result, only the last page is saved.
For example,
The problem arises when the output from more than one
SAS Graph procedures are exported to the same
Graphics Stream File using the PDF driver. If we put the
code above into a macro and run the Proc Gslide twice to
This program results in a Pdf file that only contains the
vertical bar chart run in the second procedure.
proc gchart data=sashelp.retail ; Adobe, Acrobat and the Acrobat logo are trademarks
title ’Sample Graph 1’; of Adobe Systems Incorporated which may be
hbar sales ; registered in certain jurisdictions.
run;
quit;
Contacting the Author
proc gchart data=sashelp.retail ; Please direct any questions or feedback to the author at:
title ’Sample Graph 2’;
vbar sales ; FSD Data Services, Inc.
run; 1001 S. Marshall Street
quit; Suite 125, Box 25
ods printer close;
Winston-Salem, NC 27101
This program creates the following file.
E-mail: patrickm@fsddatasvc.com