0% found this document useful (0 votes)
81 views5 pages

Creating Adobe PDF Files From Sas Graph Output: Patrick M. Mcgown, FSD Data Services, Inc., Winston-Salem, NC

This document discusses methods for creating Adobe PDF files from SAS graph output using both SAS Version 6 and Version 7. For SAS Version 6, it describes using the Adobe PDFWriter print driver to create single-page PDFs from individual graphs, and using the Adobe Distiller to translate PostScript files into multi-page PDFs when combining multiple graphs. For SAS Version 7, it directly uses the PDF device driver to output PDF files without needing additional software, allowing for both single-page and multi-page PDF creation from SAS graphs.

Uploaded by

kvkumar_2001
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views5 pages

Creating Adobe PDF Files From Sas Graph Output: Patrick M. Mcgown, FSD Data Services, Inc., Winston-Salem, NC

This document discusses methods for creating Adobe PDF files from SAS graph output using both SAS Version 6 and Version 7. For SAS Version 6, it describes using the Adobe PDFWriter print driver to create single-page PDFs from individual graphs, and using the Adobe Distiller to translate PostScript files into multi-page PDFs when combining multiple graphs. For SAS Version 7, it directly uses the PDF device driver to output PDF files without needing additional software, allowing for both single-page and multi-page PDF creation from SAS graphs.

Uploaded by

kvkumar_2001
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

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;

The resulting Pdf file looks like:

This method requires Adobe Distiller, part of the Adobe


Acrobat package but it provides a powerful tool for
generating numerous Pdfs from SAS Graph output, either
single page or multi-page by dynamically creating the
filerefs for storing the exported graphs. The following
macro creates three two-page postscript files by using the
macro variable FILENAME to assign the fileref for each
file.

%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.

Creating Single Page PDF files

The following code creates a single page Pdf file from a


single SAS Graph. The program is the same for the
single postscript file but the device is set to PDF instead
of PS300 and the file extension is PDF instead of PS.
create a two page Pdf file, only the last page is created in
the file.

filename gsasfile ’d:\projects\ssu2001_pdf\sample5b.pdf’;


%annomac;
goptions reset=all device=pdf target=ps300 gaccess=gsasfile
gsfmode=append ;
%macro test(page);
data temp;
length text $100 function color style $8;
retain xsys ysys ’3’;
%label(50,95,’Test of Annotate Output’,black,0,0,4,swiss,5);
%label(50,85,’Page ’||left(trim("&page")),black,0,0,3,swiss,5);
run;
proc gslide anno=temp;
run;
quit;
%mend;
%test(1);
%test(2);
An exception to the rule: SAS Graph Output from
Multiple SAS Graph Procedures This programs creates two pages but only the second
page is viewable in the Pdf file.
There is a problem with using the Pdf device driver to
create multi-page Pdf files from multiple SAS Graph
Procedures. The following program creates a single page
Graph output using one Proc Gslide procedure to display
simple Annotate graphics.

filename gsasfile ’d:\projects\ssu2001_pdf\sample5.pdf’;


%annomac;
goptions reset=all device=pdf target=ps300 gaccess=gsasfile
gsfmode=append ;

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,

filename gsasfile ’d:\projects\ssu2001_pdf\sample5c.pdf’;


goptions reset=all gaccess=gsasfile dev=pdf target=ps300
gsfmode=append ;
proc gchart data=sashelp.retail;
title ’Sample Graph 1’;
hbar sales;
run;
quit;
proc gchart data=sashelp.retail;
title ’Sample Graph 2’;
vbar sales;
run;
quit;

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.

The caution here is that if multiple files are to be created


using this method, the work.gseg catalog needs to be
deleted before each file is created otherwise the next file
SAS Note SN-000918 deals with this issue and provides a will contain the graph output from the current output as
solution to the problem. well as the previous output.

filename gsasfile ’d:\projects\ssu2001_pdf\sample5c.pdf’; Creating Pdfs using SAS Version 8.01


%annomac;
goptions reset=all;
goptions nodisplay device=pdf ; The major difference between Version 7 and Version 8.01
%macro annotest(page); is that for creating multi page files from a single SAS
data temp; Graph Procedure, the target device is no longer needed.
length text $100 function color style $8; The two page Pdf file can be created without specifying
retain xsys ysys ’3’; the target device.
%label(50,95,’Test of Annotate Output’,black,0,0,2,swiss,5);
%label(50,85,’Page ’||left(trim("&page")),black,0,0,1.5,swiss,5); filename gsasfile ’d:\projects\ssu2001_pdf\sample6b.pdf’;
run; goptions reset=all gaccess=gsasfile dev=pdf gsfmode=append ;
proc gslide anno=temp; proc gchart data=sashelp.retail;
run; title ’Sample Graph’;
quit; hbar sales;
%mend; vbar sales;
%annotest(1); run;
%annotest(2); quit;
goptions display gaccess=gsasfile gsfmode=append;
proc greplay nofs; Taking out the target=PS300 has no effect on the
igout work.gseg;
exporting of the graphics output except that the bars are
replay _all_;
run;
shaded instead of solid.
quit;

In this situation, the output from the two separate Gslide


procedures are stored in the work.gseg catalog and then
replayed to the Graphics Stream File using a single SAS
Graph Procedure, Proc Greplay. This allows both pages
to be created correctly in the Pdf file.

As in Version 7, if the graphics output is generated by


multiple SAS Graph procedures, the Proc Greplay method
described above must be used.
Creating Pdfs using SAS Version 8.2 Conclusion
In Version 8.2, the multiple SAS Graph Procedure output This paper provides a simple overview of creating Pdf files
to a single Graphics Stream File problem using the Pdf from SAS Graph Output. The ability to create Pdf files
driver still exists. The Adobe Distiller method or the Proc from SAS Graph Output provides a powerful tool for
Greplay method are still options in Version 8.2 using the distributing information electronically in a consistent
Pdf driver. format. The flexibility and power of SAS linked with the
universal nature of the Portable Document Format
Last but not least, ODS provides a way to generate thousands of documents that
can be made available on the web or distributed in other
In Version 8.1, ODS provided a method for exporting electronic medium.
output to Pdf files using ODS PRINTER PDF but only
under certain conditions. This was experimental in 8.1 but
is production in Version 8.2. This method allows for the References
exporting of output from multiple SAS Graph Procedures
to a single Pdf file. SAS and SAS/GRAPH are registered trademarks or
trademarks of SAS Institute Inc. in the USA and other
ods printer pdf file=’d:\projects\ssu2001_pdf\sample7c.pdf’; countries.  indicates USA registration.
goptions target=winprtg;

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

There are a couple of details worth mentioning. In order


to force the bars to be black, the goptions statement with
target=winprtg was added to format the output based on
the Windows gray scale print driver. The second detail to
note is when ODS creates the Pdf file, it also creates
bookmarks, which are located in the far left column of the
file above. In Pdf files, the bookmarks allow for moving
from page to page by clicking on any given bookmark.
The bookmark display can be hidden in Adobe Reader
under Window\Hide Bookmarks. ODS PRINTER PDF
provides a method for the direct creation of multipage Pdf
files from multiple SAS Graph Procedures.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy