Sample 24917: Generate reference lines based upon the value of a data set variable
This sample program uses PROC GPLOT to dynamically generate reference lines based upon the value of a data set variable.
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 uses PROC GPLOT to dynamically generate reference lines based upon the value of a data set variable.
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.
/* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt htext=10pt;
/* Specify macro debugging options */
options mprint mlogic symbolgen;
/* Create the 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
;
run;
/* Sort the data set ONE by the REF variable */
proc sort data=one;
by ref;
run;
/* Create macro variables that resolve to */
/* the values of REF. Also 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 the VREF macro */
%macro vref;
%do i=1 %to &total;
&&val&i
%end;
%mend vref;
/* Sort the data set ONE by the X variable */
proc sort data=one;
by x;
run;
/* Define SYMBOL statement */
symbol1 value=dot interpol=join color=black height=1.3 width=1;
/* Define axis statements */
axis1 order=(0 to 10 by 1) minor=none;
axis2 minor=none;
/* Add a title to the graph */
title1 'VREF values based upon variable values';
/* Generate the graph */
proc gplot;
plot y*x / vref=%vref cvref=vibg vaxis=axis1 haxis=axis2;
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 uses PROC GPLOT to dynamically generate reference lines based upon the value of a data set variable.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> GPLOT
|
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 |