Sample 24921: Use PROC GPLOT to control the axis range with macro variables
This sample code first uses PROC MEANS to calculate the minimum and maximum values in the input data set. These values are then used to create two macro variables, which are then used with the ORDER= option on an AXIS statement with PROC GPLOT to set the horizontal axis range.
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 code first uses PROC MEANS to calculate the minimum and maximum values in the input data set. These values are then used to create two macro variables, which are then used with the ORDER= option on an AXIS statement with PROC GPLOT to set the horizontal axis range.
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=9pt;
/* Create the input data set ONE */
data one;
input Date date7. AVG;
datalines;
01jan95 1
20feb95 5
10mar95 2
05apr95 4
01may95 1
01jun95 1
20jul95 5
10aug95 2
05sep95 4
01oct95 1
01nov95 1
;
run;
/* PROC MEANS is used to find the minimum and */
/* maximum values in the data set ONE. */
proc means min max noprint;
var date;
output out=dates min=mindate max=maxdate;
run;
/* Create the macro variables MINDATE and MAXDATE */
/* with the output values from PROC MEANS. */
data two;
set dates;
call symput('mindate',put(mindate,date7.));
call symput('maxdate',put(maxdate,date7.));
run;
/* Create axis definitions. */
/* Use the macro variables in the ORDER= option. */
axis1 order=("&mindate"d to "&maxdate"d by month2);
axis2 order=(0 to 10 by 2) minor=none;
/* Create symbol definitions. */
symbol1 i=spline c=vibg v=none;
/* Create pattern definitions. */
pattern1 v=s c=vibg;
/* Add a title to the graph */
title1 'Use macro variables to set the axis range';
/* Create the graph */
proc gplot data=one;
plot avg*date / haxis=axis1 areas=1
vaxis=axis2 frame cframe=beige;
format date date7.;
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 code first uses PROC MEANS to calculate the minimum and maximum values in the input data set. These values are then used to create two macro variables, which are then used with the ORDER= option on an AXIS statement with PROC GPLOT to set the horizontal axis range.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> GPLOT Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Plots ==> Area
|
Date Modified: | 2005-08-31 03:03:17 |
Date Created: | 2004-11-11 11:08:01 |
Operating System and Release Information
SAS System | SAS/GRAPH | All | n/a | n/a |