Sample 25584: Plotting three variables using PROC GPLOT
This sample is from the "SAS/GRAPH Software: Reference, Version 8", Volume 2, Chapter 21.
For additional information on the sample refer to this book.
/*+-------------------------------------------------------------+
| S A S S A M P L E L I B R A R Y |
| |
| NAME: GPLVRBL2 |
| TITLE: GPLVRBL2-Plotting Three Variables |
| PRODUCT: GRAPH |
| SYSTEM: ALL |
| KEYS: GRAPHICS GOPTIONS GPLOT AXIS SYMBOL |
| PROCS: GPLOT |
| DATA: INTERNAL |
| |
| SUPPORT: GRAPHICS STAFF UPDATE: |
| REF: SAS/GRAPH REFERENCE GUIDE |
| MISC: THIS PLOT USES INTERPOLATION. |
+-------------------------------------------------------------+*/
/* Set the graphics environment. */
goptions reset=all gunit=pct border cback=white
colors=(black red blue green)
ftext=swiss ftitle=swissb htitle=6 htext=3;
/* Create the data set CITYTEMP. */
data citytemp;
input month faren city $;
datalines;
1 40.5 Raleigh
1 12.2 Minn
1 52.1 Phoenix
2 42.2 Raleigh
2 16.5 Minn
2 55.1 Phoenix
3 49.2 Raleigh
3 28.3 Minn
3 59.7 Phoenix
4 59.5 Raleigh
4 45.1 Minn
4 67.7 Phoenix
5 67.4 Raleigh
5 57.1 Minn
5 76.3 Phoenix
6 74.4 Raleigh
6 66.9 Minn
6 84.6 Phoenix
7 77.5 Raleigh
7 71.9 Minn
7 91.2 Phoenix
8 76.5 Raleigh
8 70.2 Minn
8 89.1 Phoenix
9 70.6 Raleigh
9 60.0 Minn
9 83.8 Phoenix
10 60.2 Raleigh
10 50.0 Minn
10 72.2 Phoenix
11 50.0 Raleigh
11 32.4 Minn
11 59.8 Phoenix
12 41.2 Raleigh
12 18.6 Minn
12 52.5 Phoenix
;
/* Define titles and footnotes. */
title1 'Average Monthly Temperature';
footnote1 j=l ' Source: 1984 American Express';
footnote2 j=l ' Appointment Book'
j=r 'GPLVRBL2(a) ';
/* Define symbol. */
symbol1 interpol=join
value=dot
height=3;
/* Generate a plot of three variables */
/* that produces a legend. */
proc gplot data= citytemp;
plot faren*month=city / hminor=0;
run;
/* Generate second graph with modified axes. */
footnote2 j=l ' Appointment Book'
j=r 'GPLVRBL2(b) ';
/* Define symbol characteristics. */
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;
/* Define axis characteristics. */
axis1 label=none
value=('JAN' 'FEB' 'MAR' 'APR' 'MAY' 'JUN'
'JUL' 'AUG' 'SEP' 'OCT' 'NOV' 'DEC')
order = 1 to 12 by 1
offset=(2)
width=3;
axis2 label=('Degrees' justify=right 'Fahrenheit')
order=(0 to 100 by 10)
width=3;
/* Enhance the legend. */
legend1 label=none value=(tick=1 'Minneapolis');
plot faren*month=city /
haxis=axis1 hminor=0
vaxis=axis2 vminor=1
caxis=red legend=legend1;
run;
quit;

This example shows that when your data contain a classification variable that groups data, you can use a plot request to generate a separate plot for every formatted value of the classification variable.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> GPLOT Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Elements ==> Symbols/Interpolation
|
| Date Modified: | 2005-09-01 03:03:11 |
| Date Created: | 2005-05-23 14:17:08 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | 8 TS M0 | n/a |