I want to construct a template for 3 by 2 graphs using proc greplay. I don't quite understand the syntax of PROC GREPLAY and TDEF statement. I have found a template of 2 by 3 here http://support.sas.com/kb/44/973.html. Could anyone help me with the template language?
Here's the example you cited with some added comments; ...
data widgets;
input region :$10. Type :$7. 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
;
* BY-GROUP processing is used in PROC GCHART so the data are sorted by region;
proc sort data=widgets;
by region;
run;
goptions reset=all;
axis1 value=(angle=0 rotate=0);
axis2 minor=none label=(angle=90 'Total Sales');
* GCHART produces 6 charts, 1 for each BY-GROUP;
* in addition to the regular output, entries are made in the catalog WORK.GSEG;
* they can be used later to replay the chart;
* since the NAME option is not used to name the catalog entries;
* GCHART provides names ... see below;
proc gchart data=widgets;
vbar type / sumvar=sales subgroup=type maxis=axis1 raxis=axis2 nolegend;
by region;
run;
quit;
* what are the names of the charts in the catalog;
proc catalog cat=work.gseg;
contents;
run;
CONTENTS ...
Contents of Catalog WORK.GSEG
# Name Type Create Date Modified Date Description
1 GCHART GRSEG 10/12/2015 11:30:03 10/12/2015 11:30:03 Bar chart of Type
2 GCHART1 GRSEG 10/12/2015 11:30:03 10/12/2015 11:30:03 Bar chart of Type
3 GCHART2 GRSEG 10/12/2015 11:30:03 10/12/2015 11:30:03 Bar chart of Type
4 GCHART3 GRSEG 10/12/2015 11:30:03 10/12/2015 11:30:03 Bar chart of Type
5 GCHART4 GRSEG 10/12/2015 11:30:03 10/12/2015 11:30:03 Bar chart of Type
6 GCHART5 GRSEG 10/12/2015 11:30:03 10/12/2015 11:30:03 Bar chart of Type
* run GREPLAY ... ;
* IGOUT is the catalog that contains the info to reproduce the charts;
* the TDEF statement allows you to create your own template;
* by defining windows using the lower left x (LLX), lower felt y (LLY), etc. ;
* in which specific charts in the catalog are displayed;
* (the numbers are PERCENTAGES of the entire replay window);
* 6 smaller windows are defined witjhin the entire replay window;
* the TEMPLATE statement says to use a specific template ... the one just defined;
* the TREPLAY statement says to display a specific chart in a specific window;
* for example ... 1:1 means IN WINDOW #1 : DISPLAY ENTRY #1 IN THE WORK.GSEG CATALOG;
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;
NOTE: you could also use the chart NAMES (not their entry numbers) in the TREPLAY statement ...
treplay 1:gchart 2:gchart1 3:gchart2 4:gchart3 5:gchart4 6:gchart5;
Hopefully the comments help you a bit.
A simpler alternative is provided by SGPANEL. To build on @MikeZdeb example above,
proc sgpanel data=widgets noautolegend;
panelby region / columns=3 spacing=10 novarname;
vbarparm category=type response=sales / group=type;
run;
To add to https://communities.sas.com/t5/user/viewprofilepage/user-id/462 , using GREPLAY will affect the sixe of items displayed in the original chart procedure, often making any text such as axis or value labels too small to read as well as often changing aspect ratios and rendeing some line size/colors difficult to read. Which often leads to a cycle of adjust settings using AXIS, SYMBOL and PATTERN statements, recreating the graphs and replaying until you get something useable. SGPANEL will adjust most of these to fit within the current ods graph size restrictions and remain readable.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.