Sample 24928: Display the BY group as name and description with graphics output
This sample program creates GRSEG entries with the BY group value as the name and as part of the description field on the catalog entry.
While this sample program actually produces a total of four graphs, only the first graph is shown in the Results tab for this sample.
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 program creates GRSEG entries with the BY group value as the name and as part of the description field on the catalog entry.
While this sample program actually produces a total of four graphs, only the first graph is shown in the Results tab for this sample.
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 graphs from WORK.GSEG */
proc greplay nofs igout=work.gseg;
delete _all_;
run;
quit;
/* Create a sample data set */
data one;
input Date date7. Y Z $;
datalines;
01jan96 2 A
01apr96 3 A
01jul96 5 A
01oct96 4 A
01jan96 4 B
01apr96 4 B
01jul96 3 B
01oct96 4 B
01jan96 2 C
01apr96 3 C
01jul96 4 C
01oct96 3 C
01jan96 2 D
01apr96 3 D
01jul96 5 D
01oct96 8 D
;
run;
/* Sort the data set by Z */
proc sort;
by z;
run;
data new;
set one end=eof;
by z;
if first.z then do;
total+1;
/* Create the macro variables used in WHERE statement*/
call symput('z'||left(total),left(trim(z)));
end;
/* Create macro variable for the %DO loop to determine number of iterations */
if eof then call symput('total',total);
run;
/* Create a GPLOT entry for each value of Z in the WORK.GSEG */
/* catalog using macro variables to include the BY value as the */
/* entry name and part of the description. */
%macro gplot;
%do i=1 %to &total;
proc gplot data=one;
plot y*date / name="&&z&i" des="This is BY group: &&z&i"
haxis=axis1 vaxis=axis1;
where z="&&z&i";
/* Generate the By-group value on title */
title1 "The name of this graph entry is WORK.GSEG.&&z&i...GRSEG";
symbol1 v=dot i=join c=vibg h=1.4;
format date date7.;
axis1 minor=none offset=(4pct,4pct);
run;
quit;
%end;
%mend gplot;
/* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt htext=10pt;
/* Invoke the GPLOT macro */
%gplot
/* List contents of the WORK.GSEG catalog in the SAS Log */
proc greplay nofs igout=work.gseg;
list igout;
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.
This sample program creates GRSEG entries with the BY group value as the name and as part of the description field on the catalog entry.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> GPLOT
|
Date Modified: | 2005-08-31 03:03:19 |
Date Created: | 2004-11-11 11:08:02 |
Operating System and Release Information
SAS System | SAS/GRAPH | All | n/a | n/a |