The sample code on the Full Code tab demonstrates how to use PROC GREPLAY to put four PROC SGPLOT outputs on the same PDF page. Since the Statistical Graphics (SG) procedures such as SGPLOT, SGPANEL, SGSCATTER, and SGRENDER, as well as graphics produced by the ODS GRAPHICS ON statement, do not write any GRSEG entries to a SAS/GRAPH® catalog, using a procedure such as SGPLOT with PROC GREPLAY involves the following three-step process:
Step 1: Use the SG procedures or ODS Graphics to write multiple PNG files to disk.
Step 2: Use PROC GSLIDE with the IBACK= and IMAGESTYLE= graphics options to read the PNG files created in step 1 back into SAS®.
Step 3: Use PROC GREPLAY to "replay" the graphs read in to SAS during step 2.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
%macro delcat(catname);
%if %sysfunc(cexist(&catname))
%then %do;
proc greplay nofs igout=&catname;
delete _all_;
run;
quit;
%end;
%mend delcat;
%delcat(work.gseg)
%let outdir=%trim(%sysfunc(pathname(work)));
options orientation=landscape nodate nonumber;
goptions reset=all;
/* This step uses multiple PROC SGPLOT procedures */
/* to write multiple PNG files to disk. Note that */
/* this step uses the IMAGENAME= option on the ODS */
/* GRAPHICS ON statement to name each PNG file */
/* that is written to disk. */
ods _all_ close;
ods listing gpath="&outdir" image_dpi=300;
ods graphics on / reset=index imagename='sgplot1'
width=5in height=3.8in;
title1 'First SGPLOT Output';
proc sgplot data=sashelp.class;
vbar age / response=weight stat=mean;
where sex="F";
run;
ods graphics on / reset=index imagename='sgplot2'
width=5in height=3.8in;
title1 'Second SGPLOT Output';
proc sgplot data=sashelp.class;
vbar age / response=height stat=mean;
where sex="F";
run;
ods graphics on / reset=index imagename='sgplot3'
width=5in height=3.8in;
title1 'Third SGPLOT Output';
proc sgplot data=sashelp.class;
vbar age / response=weight stat=mean;
where sex="M";
run;
ods graphics on / reset=index imagename='sgplot4'
width=5in height=3.8in;
title1 'Fourth SGPLOT Output';
proc sgplot data=sashelp.class;
vbar age / response=height stat=mean;
where sex="M";
run;
ods listing;
/* This step uses PROC GSLIDE with the IBACK= and */
/* IMAGESTYLE= graphics options to read the PNG */
/* files created in step 1 back into SAS. */
goptions reset=all device=png300 nodisplay
xmax=5in ymax=3.8in;
goptions iback="&outdir./sgplot1.png" imagestyle=fit;
proc gslide;
run;
quit;
goptions iback="&outdir./sgplot2.png" imagestyle=fit;
proc gslide;
run;
quit;
goptions iback="&outdir./sgplot3.png" imagestyle=fit;
proc gslide;
run;
quit;
goptions iback="&outdir./sgplot4.png" imagestyle=fit;
proc gslide;
run;
quit;
/* This final step uses PROC GREPLAY to put four */
/* SGPLOT outputs on the same PDF page. */
goptions reset=all device=sasprtc;
ods listing close;
ods pdf file="&outdir./greplay_sgplot.pdf" notoc dpi=300;
proc greplay igout=work.gseg nofs tc=sashelp.templt
template=L2R2;
treplay 1:1 2:3 3:2 4:4;
run;
quit;
ods pdf close;
ods listing;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
This sample code creates PDF output.
Type: | Sample |
Date Modified: | 2010-11-01 11:26:04 |
Date Created: | 2010-11-01 09:39:48 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS/GRAPH | z/OS | 9.2 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |||
Microsoft® Windows® for x64 | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |||
Microsoft Windows XP Professional | 9.2 TS1M0 | |||
Windows Vista | 9.2 TS1M0 | |||
Windows Vista for x64 | 9.2 TS1M0 | |||
64-bit Enabled AIX | 9.2 TS1M0 | |||
64-bit Enabled HP-UX | 9.2 TS1M0 | |||
64-bit Enabled Solaris | 9.2 TS1M0 | |||
HP-UX IPF | 9.2 TS1M0 | |||
Linux | 9.2 TS1M0 | |||
Linux for x64 | 9.2 TS1M0 | |||
OpenVMS on HP Integrity | 9.2 TS1M0 | |||
Solaris for x64 | 9.2 TS1M0 |