Sample 24946: Dynamically replay graphs to individual GIF files using PROC GREPLAY
This sample codes uses PROC GREPLAY with macro code to dynamically replay all of the entries in a graphics catalog to individual GIF files.
While this sample code creates a total of four graphs, the Results tab only displays the first graph that the code creates.
See SAS Sample 37703 for sample code which is similar to this example but uses CALL EXECUTE within DATA step code instead of PROC GREPLAY.
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.
This sample codes uses PROC GREPLAY with macro code to dynamically replay all of the entries in a graphics catalog to individual GIF files.
While this sample code creates a total of four graphs, the Results tab only displays the first graph that the code creates.
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.
/* Delete all of the old entries in the */
/* WORK.GSEG catalog if necessary */
proc greplay nofs igout=work.gseg;
delete _all_;
run;
quit;
/* Set macro debugging options */
options mlogic symbolgen mprint;
/* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt htext=10pt;
/* Specify the NODISPLAY graphics option */
goptions device=gif nodisplay
xpixels=600 ypixels=400;
/* Write the multiple graphs to WORK.GSEG */
axis1 label=none minor=none;
title1 'First Graph';
proc gchart data=sashelp.class gout=work.gseg;
vbar age / discrete raxis=axis1 width=12;
run;
quit;
title1 'Second Graph';
proc gchart data=sashelp.class gout=work.gseg;
vbar height / raxis=axis1 width=12;
run;
quit;
title1 'Third Graph';
proc gchart data=sashelp.class gout=work.gseg;
vbar weight / raxis=axis1 width=12;
run;
quit;
title1 'Fourth Graph';
proc gchart data=sashelp.class gout=work.gseg;
vbar height / raxis=axis1 width=12;
run;
quit;
/* Use DSGI function NUMGRAPH to determine number of entries */
/* in WORK.GSEG catalog. Create macro variable that resolves */
/* to the total number of entries to be used as a loop counter */
/* in MACRO %DO loop. */
data _null_;
rc=gset('catalog','work','gseg');
rc=ginit();
call gask('numgraph',grsegcnt,rc);
call symput('grsegcnt',grsegcnt);
rc=gterm();
run;
/* Define macro to replay all entries in WORK.GSEG. */
/* Specify FILENAME and GOPTIONS to create GIF files. */
%macro grep;
%do i=1 %to &grsegcnt;
filename test&i "c:\temp\g24946&i..gif";
goptions display gsfname=test&i gsfmode=replace;
proc greplay nofs igout=work.gseg;
replay &i;
run;
quit;
filename test&i clear;
%end;
%mend grep;
/* Invoke the macro to create the graphs */
%grep
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.
This sample codes uses PROC GREPLAY with macro code to dynamically replay all of the entries in a graphics catalog to individual GIF files.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> GREPLAY
|
Date Modified: | 2005-09-01 03:03:08 |
Date Created: | 2004-11-11 11:08:05 |
Operating System and Release Information
SAS System | SAS/GRAPH | All | n/a | n/a |