Sample 45150: Use PROC GREPLAY to place six graphs on a single page in an RTF document
The sample code on the
Full code tab first uses one PROC GCHART step with a BY statement to write six graphs to the default graphics catalog of WORK.GSEG. In a final step, the GREPLAY procedure together with the ODS RTF statement are used to write the six GCHART graphs to a single page in the RTF document.
The GREPLAY step uses the TDEF statement to define a custom six-panel template. The GREPLAY step uses this newly created template to place six graphs on the same page with three graphs across the page and two graphs down the page.
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 uses the PNG300 device driver, which is new beginning with SAS® 9.2. If you are using a release of SAS prior to 9.2, replace the PNG300 device driver with the PNG device driver in both of the GOPTIONS statements in the code.
/* Delete any old graphs that exist in the */
/* default graphics catalog of 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)
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;
/* This section of code writes the original */
/* six graphs to the WORK.GSEG catalog. */
goptions reset=goptions device=PNG300
nodisplay xmax=3.7in ymax=3.5in;
axis1 value=(a=0 r=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;
goptions reset=all device=png300
xmax=10in ymax=7in;
/* Use PROC GREPLAY together with the ODS RTF statement */
/* to write six graphs to a single page in the RTF */
/* document. Note that the GREPLAY code creates a */
/* custom six-panel template. */
ods listing close;
ods rtf file='greplay.rtf';
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 rtf 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 illustrates how to use PROC GREPLAY to place six graphs on a single page in an RTF document.
Date Modified: | 2012-02-06 16:07:04 |
Date Created: | 2011-12-14 16:42:09 |
Operating System and Release Information
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 | |