SAS/GRAPH Output |
If you want to store multiple graphs in a single graphics output file, you can use either the GSFMODE=APPEND and GSFNAME= graphics options, or the GREPLAY procedure.
Using Graphics Options to Store Multiple Graphs in One Graphics Output File |
You can use the GSFMODE=APPEND and the GSFNAME= graphics options to store multiple graphs in one graphics output file. When the GSFMODE= graphics option is set to APPEND and the GSFNAME= option points to a file, if the graphics output file specified by the GSFNAME= option already exists, the SAS/GRAPH software appends the new graph to the graphics output file. Otherwise, it creates the graphics output file and stores the graph in it.
Note: Although a file can contain multiple graphs, some viewers can view only one graph. This can make it appear that a file containing multiple graphs contains only one graph.
A common application of the GSFMODE=APPEND option is in the production of animated GIFs. See Developing Web Presentations with the GIFANIM Device.
Using the GREPLAY Procedure to Store Multiple Graphs in One Graphics Output File |
You can use the GOUT= procedure option with the GREPLAY procedure to store multiple graphs in one graphics output file. This involves the following steps:
Create a file reference for your output file. For example:
filename myfile "MyOutputFile.ps";
Run the procedure to generate your charts and store them in a catalog.
Add the GSFNAME=FileRefName to your GOPTIONS statement.
Run the GREPLAY procedure as follows:
proc greplay igout=<CatalogName> replay _all_; run; quit;
Replace <CatalogName> with the name of the catalog in which your graphs are stored. The REPLAY _ALL_ action statement replays all of the entries in the catalog.
Here is an example that replays five graphs to one PostScript file for printing.
/* Specify graphics output file name */ filename psout "multicharts.ps"; /* Specify style and graphics options */ ods listing style=banker; goptions reset=all device=pscolor gsfname=psout nodisplay; /* Generate the graphs */ proc gchart data=sashelp.cars gout=Work.Mygraphs; vbar Make; title1 "30 MPG or better"; where MPG_Highway > 30; run; vbar Make; title1 "Between 25 MPG and 29 MPG"; where MPG_Highway >= 25 AND MPG_Highway <= 29; run; vbar Make; title1 "Between 20 MPG and 24 MPG"; where MPG_Highway >= 20 AND MPG_Highway <= 24; run; vbar Make; title1 "Between 15 MPG and 19 MPG"; where MPG_Highway >= 15 AND MPG_Highway <= 19; run; vbar Make; title1 "Less than 15 MPG"; where MPG_Highway < 15; run; quit; /* Enable display, and then replay all of the graphs to psout */ goptions display; proc greplay igout=Work.Mygraphs nofs; replay _all_; run; quit;
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.