Sample 24932: Display the left and right axes with combined legend
/* Set graphics environment */
goptions reset=all border;
/* Create input data set, A */
data a;
input x y1 y2 y3 y4;
datalines;
1 2 50 . 100
2 2 50 . 400
3 2 50 . 200
;
/* Create symbol definitions */
symbol1 i=j v=dot c=blue w=3;
symbol2 i=j v=dot c=green w=3;
symbol3 i=j v=dot c=red w=3;
symbol4 i=j v=dot c=red w=3;
/* Create axis definitions */
axis1 order=(0 to 5 by 1);
axis2 order=(0 to 100 by 10);
axis3 order=(0 to 1000 by 100);
/* Create legend definition */
legend1 value=(tick=3 'new_y4') across=1;
/* Create title */
title1 'Combined Legend';
/* Produce plot */
proc gplot data=a;
plot y1*x=1 y2*x=2 y3*x=3 / overlay haxis=axis1 vaxis=axis2 legend=legend1;
plot2 y4*x=4 / vaxis=axis3 ;
run;
quit;

A PLOT and PLOT2 statement is used to create both left and right axes. The OVERLAY and LEGEND options are used in combination to create a legend. A LEGEND statement is used to define characteristics to produce one legend with all values.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> GPLOT Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Elements ==> Legends
|
| Date Modified: | 2005-08-31 03:03:20 |
| Date Created: | 2004-11-11 11:08:02 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | n/a | n/a |