UCLA Academic Technology Services HomeServicesClassesContactJobs
Help the Stat Consulting Group by giving a gift             
Loading

SAS FAQ
How to can I use proc greplay to display multiple plots at the same time?

Oftentimes we create multiple graphs for a single purpose.  We might make several graphs as a way of describing a variable or variables in our data set, or we might make several graphs to assess the fit of a model to our data.  While each graph by itself is useful, seeing all of the graphs on the same page is even more helpful.  There are two ways that you can accomplish this in SAS using proc greplay.  One method requires a SAS program to be written, and the other method uses a point-and-click interface.

Let us suppose that we have used the hsb2.sas7bdat data set, run a regression model and created several diagnostic plots that we would like to see on a single page, two plots down one side and two down the other.  Below is the program for obtaining the regression and the plots.

proc reg data = hsb2;
  model write = math female science schtyp;
   plot predicted.*residual. residual.*math cookd.*predicted.
   h.*predicted. ;
run;
quit;

Method 1:  Before we begin writing our SAS program, we need to know the locations of some things.  First, by default, the graphs created by proc reg (and all other procs) are located in the work directory in a graph catalogue called gseg.  You can see that your graphs are there by clicking on explorer (in the lower left corner of your SAS screen), then libraries, work and gseg.  The graphs will have names like reg, reg1, reg2, etc., because they were produced by proc reg.  Another location that you need to know, if you want to use the layout templates provided by SAS (as opposed to making your own layout template), is that they are located in a folder called sashelp.templt.  You will also need to know the name of the template that  you want to use.  We will use the one called l2r2, which means that there are two graphs on the left side and two graphs on the right.  Now we are ready to write our SAS program.

proc greplay igout=work.gseg tc=sashelp.templt
             template=l2r2 nofs;
   treplay 1:reg 2:reg1 3:reg2 4:reg3;
run;
quit;

In the program above, the igout = option on the proc greplay statement tells SAS where the graphs are.  The tc = option tells SAS where the layout template is located.  The template = option indicates that template that we want to use, and the nofs option tells SAS to use the line mode, which allows the graphs to be displayed properly.  On the treplay statement we indicate into which cell of the graph layout template we want each graph to appear.

Method 2:  You can also use the interactive mode of proc greplay in a step-by-step fashion.

         proc greplay;
         run;


How to cite this page

Report an error on this page or leave a comment

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.