The code first creates PROC GCHART output (which takes up the left hand side of the page). The code then creates PROC GPLOT output (which occupies the right hand side of the page). The final graph is created by using PROC GREPLAY to overlay the two graphs on top of each other using the WHOLE template.
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 code first creates PROC GCHART output (which takes up the left hand side of the page). The code then creates PROC GPLOT output (which occupies the right hand side of the page). The final graph is created by using PROC GREPLAY to overlay the two graphs on top of each other using the WHOLE template.
The graphics output in 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.
/* Use this step to delete all of the old graphs */
/* from WORK.GSEG if necessary */
proc greplay igout=work.gseg nofs;
delete _all_;
run;
quit;
/* Create a sample data set */
data yearly;
input Year YR_AVG Site $;
datalines;
91 10 Site_A
91 20 Site_B
92 40 Site_A
92 30 Site_B
93 20 Site_A
93 15 Site_B
94 32 Site_A
94 13 Site_B
95 28 Site_A
95 17 Site_B
;
run;
data monthly;
input Month MON_AVG Site $;
datalines;
1 15 Site_A
2 30 Site_A
3 10 Site_A
4 18 Site_A
5 5 Site_A
6 6 Site_A
7 9 Site_A
8 7 Site_A
9 5 Site_A
10 8 Site_A
11 9 Site_A
12 6 Site_A
1 2 Site_B
2 4 Site_B
3 1 Site_B
4 4 Site_B
5 2 Site_B
6 5 Site_B
7 2 Site_B
8 1 Site_B
9 4 Site_B
10 5 Site_B
11 3 Site_B
12 2 Site_B
;
run;
data anno1;
length function color $8;
retain function 'label' color 'black' when 'a' position '2' xsys '2' ysys '2';
set yearly;
midpoint=year; subgroup=site;
text=left(put(yr_avg,2.));
run;
/* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt htext=10pt;
goptions nodisplay;
axis1 origin=(16,16)pct label=none length=40 pct offset=(3,3)pct;
axis2 order=(0 to 100 by 20) length=75 pct minor=none;
legend1 position=(top left inside) label=('Yearly') across=1;
pattern1 value=solid color=CX7C95CA;
pattern2 value=solid color=CXDE7E6F;
/* Create the output from GCHART so that it */
/* only takes up the left hand side of the page */
proc gchart data=yearly;
vbar year / sumvar=yr_avg maxis=axis1 noframe
legend=legend1 subgroup=site discrete
raxis=axis2 anno=anno1 width=6;
run;
quit;
axis1 origin=(55,16)pct label=none length=40 pct
offset=(3,3)pct order=(1 to 12 by 1)
value=('J' 'F' 'M' 'A' 'M' 'J' 'J' 'A' 'S' 'O' 'N' 'D')
minor=none;
axis2 order=(0 to 100 by 20) length=75 pct
value=none label=none
minor=none major=none origin=(55,16)pct color=white;
legend1 position=(top center inside) label=('Monthly') across=1;
symbol1 i=j v=none c=CX7C95CA line=1 w=2;
symbol2 i=j v=none c=CXDE7E6F line=1 w=2;
title1 move=(40,95)pct 'AVERAGES';
/* Create the output from PROC GPLOT so that it */
/* takes up the right hand side of the page. */
proc gplot data=monthly;
plot mon_avg*month=site / legend=legend1 haxis=axis1 vaxis=axis2 noframe;
run;
quit;
goptions display;
/* Use the WHOLE template with GREPLAY to overlay */
/* the two graphs on the same page. */
proc greplay igout=work.gseg nofs tc=sashelp.templt
template=whole;
treplay 1:gchart 1:gplot;
run;
quit;
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.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> GREPLAY |
Date Modified: | 2005-09-01 03:03:07 |
Date Created: | 2004-11-11 11:08:04 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS/GRAPH | All | n/a | n/a |