Proc gplot is used to make presentation quality graphs. Crude graphs can be made using proc plot.
Options controlling the hardware available for SAS to use for the high quality graphics procedures are specified in the goptions statement. Read about the goptions statement before continuing.
To illustrate the basics, suppose the dataset quad contains the
values of y=x**2 for x=1,...,10. A nice plot of this quadratic is
desired. The basic plot is obtained as follows.
proc gplot
data=quad;
plot y*x;
run;
The result of these commands will depend on the interpol setting in
the goptions statement. If interpol=join is set, the 10
data points will be connected by straight lines.
By default, the axes are scaled automatically. The invocation
proc gplot
data=quad;
plot y*x/ haxis=0,5,10 vaxis=0 to 120 by 20;
run;
gives tick marks at 0,5, and 10 on the horizontal axis, and marks the vertical axis at intervals of 20 from 0 to 120. This illustrates the two methods of manual scaling.
For a more elaborate example with the same data:
proc gplot
data=quad;
title `My First Plot';
title2 `A Simple Quadratic';
plot y*x /vref=4 href=16;
symbol interpol=join l=3 w=5;
run;
The vref= option draws a horizontal line at y=4; the href=
option draws a vertical line at x=16.
The symbol statement specifies the interpolation method (here join),
the line style (l=3) specifies the type of line to draw, and the
width option (w=5) makes the line 5 times its normal thickness. (The
w option is not supported on all devices.) SYMBOL STATEMENTS ARE
GLOBAL. This symbol statement will be used by all subsequent graphs.
Multiple plots can be made in 3 ways.
proc gplot
data=junk;
plot y*x z*x /overlay;
run;
plots y versus x and z versus
x using the same horizontal and vertical axes.
proc gplot
data=junk;
plot y*x;
plot2 z*x;
run;
plots y versus x and z versus
x using different vertical axes. The second vertical axes
appears on the right hand side of the graph.
proc gplot
data=junk;
plot y*x=z
run;
uses z as a classification variable and will produce a
single graph plotting y against x for each
value of the variable z.
proc gplot
data=junk;
plot y*x;
by z;
run;
produces separate graphs of y against x for
each value of z.
For additional information see the SAS/GRAPH User's Guide.
Copyright © 1997 by Jerry Alan Veeh. All rights reserved.