GREPLAY Procedure

Example 3: Replaying Graphs into a Template

Features:
GREPLAY statement options::
IGOUT=
GOUT=
NOFS
TC=
TEMPLATE=

DEVICE statement

TREPLAY statement

This example replays four graphs into template L2R2. The following figure shows the output of this example program.
Template Output

Program

data sasuser.class (drop=name );
   length Gender $ 6;
   set sashelp.class;
   if sex="F" then Gender="Female";
      else Gender="Male";
run;
proc sort data=sasuser.class out=sasuser.class;
   by weight height;
run;
     
  goptions reset=all hsize=2.75in vsize=2.06in; 
ods html close;
ods listing;
axis1 label=none style=0 major=none value=none;
axis2 label=("Age");
axis3 label=("Height") order=50 to 75 by 5;
axis4 label=("Weight") order=50 to 150 by 25 minor=(n=1);
legend1 label=none value=("Male" "Female") Position=(right middle outside)
across=1;
legend2 label=none value=("Male" "Female"); 
symbol i=join; 
proc gchart data=sasuser.class gout=sasuser.excat;
   vbar age/discrete hminor=0 subgroup=gender
                 inside=freq  raxis=axis1 maxis=axis2
                 noframe legend=legend1;
run;
   hbar age/ discrete sumvar=height mean
                  meanlabel="Avg.Height" vminor=0
                  raxis=axis1 maxis=axis2;
run;
   pie gender/ noheading legend=legend1 percent=inside;
run;
proc gplot data=sasuser.class gout=sasuser.excat;
    plot height*weight=gender/ vminor=1 vaxis=axis3
    haxis=axis4 legend=legend2;
run;
quit;
goptions reset=all hsize=5.5in vsize=4.12in; 
proc greplay gout=sasuser.excat igout=sasuser.excat nofs
   tc=sashelp.templt template=l2r2;
   device win;
   treplay 1:gchart 2:gchart1 3:gchart2 4:gplot;
quit; 
ods listing close;
ods html;

Program Description

Here is a detailed example of the example program.
Prepare the data for the graphs. Drop variables NAME and SEX, and add a variable called GENDER. Change variable values, and sort the data for the line graph.
data sasuser.class (drop=name );
   length Gender $ 6;
   set sashelp.class;
   if sex="F" then Gender="Female";
      else Gender="Male";
run;
proc sort data=sasuser.class out=sasuser.class;
   by weight height;
run;
     
Define the size of each individual graph. Each graph is replayed into a separate panel in the template.
  goptions reset=all hsize=2.75in vsize=2.06in; 
Close ODS HTML and open ODS LISTING.
ods html close;
ods listing;
Create axes definitions for the graphs.
axis1 label=none style=0 major=none value=none;
axis2 label=("Age");
axis3 label=("Height") order=50 to 75 by 5;
axis4 label=("Weight") order=50 to 150 by 25 minor=(n=1);
Create legend definitions for the graphs.
legend1 label=none value=("Male" "Female") Position=(right middle outside)
across=1;
legend2 label=none value=("Male" "Female"); 
Create a symbol definition for the plot.
symbol i=join; 
Generate the graphs, and store them in the SASUSER.EXCAT catalog. Generate a vertical bar chart, a horizontal bar chart, a pie chart, and a subgrouped plot.
proc gchart data=sasuser.class gout=sasuser.excat;
   vbar age/discrete hminor=0 subgroup=gender
                 inside=freq  raxis=axis1 maxis=axis2
                 noframe legend=legend1;
run;
   hbar age/ discrete sumvar=height mean
                  meanlabel="Avg.Height" vminor=0
                  raxis=axis1 maxis=axis2;
run;
   pie gender/ noheading legend=legend1 percent=inside;
run;
proc gplot data=sasuser.class gout=sasuser.excat;
    plot height*weight=gender/ vminor=1 vaxis=axis3
    haxis=axis4 legend=legend2;
run;
quit;
Define the size of each the template. Each graph is replayed into a separate panel in the template. The template size accommodates the four smaller graphs.
goptions reset=all hsize=5.5in vsize=4.12in; 
Replay the graphs with a template to create one graph. The graphs stored in SASUSER.EXCAT are replayed to create one graph. The graph is also stored in the SASUSER.EXCAT catalog.
proc greplay gout=sasuser.excat igout=sasuser.excat nofs
   tc=sashelp.templt template=l2r2;
   device win;
   treplay 1:gchart 2:gchart1 3:gchart2 4:gplot;
quit; 
Close ODS LISTING and open ODS HTML.
ods listing close;
ods html;