Sample 25582: Plotting with different scales of values using PROC GPLOT
This sample demonstrates how to use a PLOT2 statement with PROC GPLOT. This sample code generates a right vertical axis that displays the values of the vertical coordinates in a different scale from the scale that is used for the left vertical axis.
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 demonstrates how to use a PLOT2 statement with PROC GPLOT. This sample code generates a right vertical axis that displays the values of the vertical coordinates in a different scale from the scale that is used for the left vertical axis.
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 border cback=white htitle=11pt;
/* Create the data set MINNTEMP */
data minntemp;
input @10 month
@23 f2; /* Fahrenheit temperature for Minneapolis */
/* Calculate Centigrade temperature */
/* for Minneapolis */
c2=(f2-32)/1.8;
output;
datalines;
01JAN83 1 1 40.5 12.2 52.1
01FEB83 2 1 42.2 16.5 55.1
01MAR83 3 2 49.2 28.3 59.7
01APR83 4 2 59.5 45.1 67.7
01MAY83 5 2 67.4 57.1 76.3
01JUN83 6 3 74.4 66.9 84.6
01JUL83 7 3 77.5 71.9 91.2
01AUG83 8 3 76.5 70.2 89.1
01SEP83 9 4 70.6 60.0 83.8
01OCT83 10 4 60.2 50.0 72.2
01NOV83 11 4 50.0 32.4 59.8
01DEC83 12 1 41.2 18.6 52.5
;
run;
/* Define title and footnotes */
title1 'Average Monthly Temp for Minneapolis';
footnote1 j=l ' Source: 1984 American Express';
footnote2 j=l ' Appointment Book'
j=r 'GPLSCVL1 ';
footnote3 ' ';
/* Define symbol characteristics */
symbol1 interpol=needle ci=blue cv=red value=star
height=2 width=2;
symbol2 interpol=none value=none;
/* 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=1;
axis2 label=('Degrees' justify=right ' Centigrade')
order=(-20 to 30 by 10)
width=1;
axis3 label=('Degrees' justify=left 'Fahrenheit')
order=(-4 to 86 by 18)
width=1;
/* Generate a plot with a second vertical axis */
proc gplot data= minntemp;
plot c2*month / frame
haxis=axis1 hminor=0
vaxis=axis2 vminor=1;
plot2 f2*month / vaxis=axis3 vminor=1;
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 example shows how a PLOT2 statement generates a right vertical axis that displays the values of the vertical coordinates in a different scale from the scale that is used for the left vertical axis.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> GPLOT
|
| Date Modified: | 2005-08-27 03:03:27 |
| Date Created: | 2005-05-23 14:17:00 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | 8 TS M0 | n/a |