Sample 24928: Display BY-group as name and description
/******************************************************************/
/* The purpose of this program is to create GRSEG entries */
/* with the BY-group value as the name and as part of the */
/* description fields on the catalog entry */
/* */
/* NOTE: In a future release of SAS/GRAPH, the #BYVAL/#BYVAR */
/* options will be valid when used with the NAME= or DESCRIPTION= */
/* options for SAS/GRAPH procedures. */
/******************************************************************/
/* Delete entries in WORK.GSEG catalog */
proc greplay nofs igout=work.gseg;
delete _all_;
run;
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
;
/* Sort by the BY-group variable, 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 f=swiss h=1 "Entry name: WORK.GSEG.&&z&i...GRSEG";
SYMBOL1 v=dot i=join c=blue;
FORMAT date date7.;
AXIS1 minor=none;
run;
quit;
%end;
%mend gplot;
/* Invoke macro */
%gplot
/* List contents of WORK.GSEG catalog in SASLOG */
proc greplay nofs igout=work.gseg;
list igout;
run;
quit;

This sample creates GRSEG entries with the BY-group value as the name and as part of the description fields 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 |