UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

SAS FAQ
How can I output a sequence of plots to a single webpage with a frame?

SAS proc greplay can be used to place a series of graphs onto a single webpage.  That webpage can show thumbnail sketches of all of the graphs along the left side of the page and display one of the graphs full-size across the rest of the webpage.  You can click on each of the thumbnails to display it full-size.  As an example of this, let's suppose that we have done a regression analysis and have plotted a sequence of plots in proc reg

Example 1 - A general setting

We will use the hsb2.sas7bdat data set.  The SAS program below will run the regression and create webpage with the graphs.  The goptions and symbol statements restore the default SAS/Graph settings and specify the graph characteristics, respectively.  Next, we run proc reg and request four diagnostic plots.  The filename statement is used to create a folder which we have called reg8.  We have named this place grafout.  This is similar to a libname in that the name, in this case, grafout, refers to a specific folder on the local hard drive.  The device=webframe option on the second goptions statement allows us to create a web page with a frame showing one plot at a time.  We specify where the graphs are to be found using gsfname= .  We specify the horizontal size of the full-size graph with hsize= and the vertical size with vsize= .  By default, these sizes are in inches.  We then use proc greplay to output the four plots created in the proc reg as graphic files to the directory together with an HTML page, called index.html.  The page index.html created here can be viewed by clicking here.  On that page you can click on a smaller plot on the left to get a full view of the entire plot on the right.  By default, SAS stores all graphs in a temporary file called work.gseg, which you can see using the explorer in SAS.  The nofs option on the proc greplay statement is needed to use line mode.  Basically, this allows the graphs to be shown properly.  On the replay statement, you list the graphs that you would like to have displayed.  Finally, we reset all goptions to the default.  If this is omitted, graphs created after this will not display in the graph1 window.  (If you include the display option in the second goptions statement, this third goptions reset=all; statement can be omitted.)

goptions reset = all;
symbol v = star h = 1.5 c=blue;
proc reg data = hsb2;
  model write = math female science schtyp;
   plot predicted.*residual. residual.*math cookd.*predicted.
   h.*predicted. ;
run;
quit;
filename grafout "d:\temp\reg8";
goptions reset=all device=webframe 
		   gsfname=grafout hsize=5 vsize=4;
proc greplay igout=work.gseg nofs;
  replay reg reg1 reg2 reg3 ;
run;
quit;
goptions reset = all;

Example 2 - using the key word _ALL_

A simpler syntax is shown here for creating the same webpage. What is different this time is that you may have already created a few plots and you want to get rid of them before creating new ones that you need. Here is what you can do. proc greplay is used the first time to delete all the plots that have been created and located in the work directory. The proc reg is used to create all the diagnostic plots as we had in the first example. Since there are only these four plots in the catalog of Gseg in the work directory, we can use the key word _all_ to include all the plots without specifying any names of the plots. The code below creates the same webpage as the code in Example 1.

proc greplay igout = work.gseg nofs;
  delete _all_;
run;
goptions reset = all;
symbol v = star h = 1.5 c=blue;
proc reg data = hsb2;
  model write = math female science schtyp;
   plot predicted.*residual. residual.*math cookd.*predicted.
   h.*predicted. ;
run;
quit;
filename grafout "d:\temp\reg";
goptions reset=all device=webframe 
	 gsfname=grafout hsize=5 vsize=4;
proc greplay igout=work.gseg nofs;
  replay _all_;
run;
quit;

How to cite this page

Report an error on this page

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