Sample 24917: Specify VREF values from a variable
/* Reset global statements */
goptions reset=all;
/* Specify macro debug options */
options mprint macrogen symbolgen;
/* Create sample data set ONE */
data one;
input x y ref;
datalines;
1 2 .
2 4 .
3 5 .
4 3 5
5 2 .
6 4 .
7 6 7
8 2 .
9 2 .
10 5 3
;
/* Sort data set ONE by REF variable */
proc sort data=one;
by ref;
run;
/* Create macro variables that resolve to the values of REF. */
/* Create a macro variable that resolves to total non-missing values of REF */
data _null_;
set one end=eof;
by ref;
where ref NE .;
if first.ref then count+1;
call symput('val'||left(count),trim(left(ref)));
if eof then call symput('total',left(count));
run;
/* Create macro VREF */
%macro vref;
%do i=1 %to &total;
&&val&i
%end;
%mend vref;
/* Sort data set ONE by X variable */
proc sort data=one;
by x;
run;
/* Specify SYMBOL statement */
symbol1 v=dot i=join c=black;
/* Specify AXIS1 statement for vertical Y-axis */
axis1 order=(0 to 10 by 1);
/*Specify Title statement */
title1 h=2.5 'VREF values based upon variable value';
/* Generate GPLOT */
proc gplot;
plot y*x / vref=%vref cvref=blue vaxis=axis1;
run;
quit;

The purpose of this program is to dynamically generate reference lines based upon the value of a data set variable.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> GPLOT Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Elements ==> Reference Lines
|
| Date Modified: | 2005-08-31 03:03:14 |
| Date Created: | 2004-11-11 11:08:00 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | n/a | n/a |