This sample demonstrates how to use PROC GREPLAY to place six graphs on the same page in a PDF document. The sample code on the Full Code tab starts off by using PROC GCHART to write six bar charts to the default SAS/GRAPH® catalog of WORK.GSEG.
The final step in the code uses PROC GREPLAY with the ODS PDF statement to write all six graphs to a single page in the PDF document. The sample code uses the TDEF statement within PROC GREPLAY to define a custom six-panel template.
Note that the sample code uses one set of graphics options when creating the six original graphs but then uses a second set of graphics options when using GREPLAY to create the final PDF output.
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.
The sample code below starts off by using PROC GCHART to write six bar charts to the default SAS/GRAPH® catalog of WORK.GSEG.
The final step in the code uses PROC GREPLAY with the ODS PDF statement to write all six graphs to a single page in the PDF document. The sample code uses the TDEF statement within PROC GREPLAY to define a custom six-panel template.
Note that the sample code uses one set of graphics options when creating the six original graphs but then uses a second set of graphics options when using GREPLAY to create the final PDF output.
The graphics output on the Results tab was produced using SAS® 9.2. Submitting the sample code with releases of SAS prior to SAS 9.2 might produce different results.
/* Delete any graphs that exist in the */
/* default graphics catalog WORK.GSEG. */
%macro delcat(catname);
%if %sysfunc(cexist(&catname))
%then %do;
proc greplay nofs igout=&catname;
delete _all_;
run;
quit;
%end;
%mend delcat;
%delcat(work.gseg)
ods _ALL_ close;
ods listing;
data widgets;
input @1 Region $10. Type $ Sales;
datalines;
East Gadgets 5250
East Gizmos 4200
East Widgets 4930
NorthEast Gadgets 7250
NorthEast Gizmos 3200
NorthEast Widgets 5930
North Gadgets 2700
North Gizmos 4100
North Widgets 3800
Northwest Gadgets 3700
Northwest Gizmos 5100
Northwest Widgets 6800
South Gadgets 6300
South Gizmos 5900
South Widgets 5200
West Gadgets 4600
West Gizmos 2700
West Widgets 5500
;
run;
proc sort data=widgets;
by region;
run;
options orientation=landscape nodate nonumber;
/* Create the individual graphs. */
goptions reset=goptions device=sasprtc
ftext='helvetica' ftitle='helvetica'
nodisplay htext=10pt
hsize=3.66in vsize=4.25in;
axis1 value=(angle=0 rotate=0);
axis2 minor=none label=(angle=90 'Total Sales');
proc gchart data=widgets;
vbar type / sumvar=sales
subgroup=type
maxis=axis1
raxis=axis2
nolegend;
by region;
run;
quit;
/* Create the combined graph. */
goptions reset=all device=sasprtc;
ods listing close;
ods pdf file='greplay.pdf' notoc;
proc greplay nofs tc=work.templt igout=work.gseg;
tdef graf2by3 des='Six graphs: two down, three across'
1 / llx = 0 lly = 51
ulx = 0 uly = 100
urx = 33 ury = 100
lrx = 33 lry = 51
2 / llx = 34 lly = 51
ulx = 34 uly = 100
urx = 66 ury = 100
lrx = 66 lry = 51
3 / llx = 67 lly = 51
ulx = 67 uly = 100
urx = 100 ury = 100
lrx = 100 lry = 51
4 / llx = 0 lly = 0
ulx = 0 uly = 50
urx = 33 ury = 50
lrx = 33 lry = 0
5 / llx = 34 lly = 0
ulx = 34 uly = 50
urx = 66 ury = 50
lrx = 66 lry = 0
6 / llx = 67 lly = 0
ulx = 67 uly = 50
urx = 100 ury = 50
lrx = 100 lry = 0;
template graf2by3;
treplay 1:1 2:2 3:3 4:4 5:5 6:6;
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 |
Topic: | SAS Reference ==> Procedures ==> GREPLAY |
Date Modified: | 2011-11-30 13:57:28 |
Date Created: | 2011-11-29 15:48:41 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS/GRAPH | z/OS | 9.1 TS1M3 SP4 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M3 SP4 | |||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows XP 64-bit Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows 2000 Advanced Server | 9.1 TS1M3 SP4 | |||
Microsoft Windows 2000 Datacenter Server | 9.1 TS1M3 SP4 | |||
Microsoft Windows 2000 Server | 9.1 TS1M3 SP4 | |||
Microsoft Windows 2000 Professional | 9.1 TS1M3 SP4 | |||
Microsoft Windows NT Workstation | 9.1 TS1M3 SP4 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows XP Professional | 9.1 TS1M3 SP4 | |||
Windows Vista | 9.1 TS1M3 SP4 | |||
Windows Vista for x64 | 9.1 TS1M3 SP4 | |||
64-bit Enabled AIX | 9.1 TS1M3 SP4 | |||
64-bit Enabled HP-UX | 9.1 TS1M3 SP4 | |||
64-bit Enabled Solaris | 9.1 TS1M3 SP4 | |||
HP-UX IPF | 9.1 TS1M3 SP4 | |||
Linux | 9.1 TS1M3 SP4 | |||
Linux on Itanium | 9.1 TS1M3 SP4 | |||
OpenVMS Alpha | 9.1 TS1M3 SP4 | |||
Solaris for x64 | 9.1 TS1M3 SP4 | |||
Tru64 UNIX | 9.1 TS1M3 SP4 |