Chapter Contents

Previous

Next
The GPLOT Procedure

Example 8: Plotting Three Variables


Procedure features:
PLOT classification variable
Other features:
AXIS statement
SYMBOL statement
RUN-group processing
Sample library member: GR21N08

[IMAGE]

This example shows that when your data contain a classification variable that groups the data, you can use a plot request of the form y-variable*x-variable=third-variable to generate a separate plot for every formatted value of the classification variable, which in this case is CITY. With this type of request, all plots are drawn on the same graph and a legend is automatically produced and explains the values of third-variable. The default legend uses the variable name CITY for the legend label and the variable values for the legend value descriptions. Because no LEGEND definition is used in this example, the font and height of the legend label and the legend value descriptions are set by the graphics options FTEXT= and HTEXT=. Height specifications in the SYMBOL statement do not affect the size of the symbols in the legend values.

This example then modifies the plot request. As shown in the following output, the plot is enhanced by using different symbol definitions for each plot line, changing axes labels, and scaling the vertical axes differently.

[IMAGE]

 Note about code
libname reflib 'SAS-data-library';
goptions reset=global gunit=pct border cback=white
         colors=(black blue green red)
         ftitle=swissb ftext=swiss htitle=6 htext=3;
 Note about code
data reflib.citytemp;
   input  month faren city $;
   datalines;
   1      40.5    Raleigh
   1      12.2    Minn
   1      52.1    Phoenix
   ...more data lines...
  12      41.2    Raleigh
  12      18.6    Minn
  12      52.5    Phoenix
;
 Note about code
title1 'Average Monthly Temperature';
footnote1 j=l ' Source: 1984 American Express';
footnote2 j=l '            Appointment Book'
          j=r 'GR21N08(a) ';
 Note about code
symbol1 interpol=join
        value=dot
        height=3;
 Note about code
proc gplot data=reflib.citytemp;
   plot faren*month=city / hminor=0;
run;
 Note about code
footnote2 j=l '         Appointment Book'
          j=r 'GR21N08(b) ';
 Note about code
symbol1 color=green interpol=spline
        width=2 value=triangle
        height=3;
symbol2 color=blue interpol=spline
        width=2 value=circle
        height=3;
symbol3 color=red interpol=spline
        width=2 value=square
        height=3;
 Note about code
axis1 label=none
      value=('JAN' 'FEB' 'MAR' 'APR' 'MAY' 'JUN'
             'JUL' 'AUG' 'SEP' 'OCT' 'NOV' 'DEC')
      offset=(2)
      width=3;
axis2 label=('Degrees' justify=right 'Fahrenheit')
      order=(0 to 100 by 10)
      width=3;
 Note about code
legend1 label=none value=(tick=1 'Minneapolis');
 Note about code
   plot faren*month=city / haxis=axis1 hminor=0
                           vaxis=axis2 vminor=1
                           caxis=red legend=legend1;
run;
quit;


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.