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";
/* Close the ODS HTML destination */
ods html close;
/* Specify the graphics options */
goptions reset=all device=pscolor gsfname=psout nodisplay;
/* Open the LISTING destination */
ods listing style=banker;
/* 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;
/* Close the LISTING destination and open the HTML destination */
ods listing close;
ods html;