Sample 24921: Control axis range with macro variables
Using PROC MEANS, the minimum and maximum values in a data set are found and assigned to macro variables which are then used in the ORDER= option on an AXIS statement to define the axis range.
Using PROC MEANS, the minimum and maximum values in a data set are found and assigned to macro variables which are then used in the ORDER= option on an AXIS statement to define the axis range.
/* Set graphics options */
goptions reset=all colors=(black) ctext=black border
ftext=swiss ;
/* Create 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=black v=none;
/* Create pattern definitions. */
pattern1 v=s c=blue;
/* Add the titles */
title1 ' ';
title2 f=swissb h=5 pct 'Average Over Time';
/* Produce the plot. */
proc gplot data=one;
plot avg*date / haxis=axis1 areas=1 vaxis=axis2 frame;
format date monname3.;
run;
quit;

Using PROC MEANS, the minimum and maximum values in a data set are found and assigned to macro variables which are then used in the ORDER= option on an AXIS statement to define the axis range.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> GPLOT Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Elements ==> Axis
|
| 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 |