Sample 49568: Add a right vertical axis to a graph generated with the Graph Template Language (GTL)
In order to give a better indication of the values for particular data points, you might want to display a right vertical axis on your graph. Adding a second Y axis is not feasible for bar charts using the ODS Graphics Statistical Graphics (SG) procedures such as PROC SGPLOT. However, with the Graph Template Language (GTL), you can plot the data values on the right vertical axis by including the YAXIS=Y2 option in the SCATTERPLOT statement.
See the sample code on the Full Code tab for an illustration.
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.
In order to give a better indication of the values for particular data points, you might want to display a right vertical axis on your graph. Adding a second Y axis is not feasible for bar charts using the ODS Graphics Statistical Graphics (SG) procedures such as PROC SGPLOT. However, with the Graph Template Language (GTL), you can plot the data values on the right vertical axis by including the YAXIS=Y2 option in the SCATTERPLOT statement.
data simple;
input Topic Sum Partial;
datalines;
1 50 24
1 30 10
2 75 10
3 40 37
3 12 19
4 100 75
5 60 40
;
run;
proc template;
define statgraph vbarscat;
begingraph;
entrytitle 'Overlay Bar Chart and Scatter Plot';
entryfootnote halign=left 'Sum is represented with the left vertical axis';
entryfootnote halign=left 'Partial is represented with the right vertical axis';
layout overlay / yaxisopts=(linearopts=(viewmin=0 viewmax=80
tickvaluesequence=(start=0 end=80 increment=10)));
barchart x=Topic y=Sum / name='bar';
scatterplot x=Topic y=Partial / yaxis=y2 name='scatter';
discretelegend 'bar' 'scatter';
endlayout;
endgraph;
end;
run;
proc sgrender data=simple template=vbarscat;
run;
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 illustrates how to add a right vertical axis to a graph generated with the Graph Template Language (GTL).
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> SGRENDER
|
Date Modified: | 2013-04-18 13:32:36 |
Date Created: | 2013-04-02 16:56:01 |
Operating System and Release Information
SAS System | SAS/GRAPH | z/OS | 9.2 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |
Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |
Microsoft® Windows® for x64 | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |
Microsoft Windows XP Professional | 9.2 TS1M0 | |
Windows Vista | 9.2 TS1M0 | |
Windows Vista for x64 | 9.2 TS1M0 | |
64-bit Enabled AIX | 9.2 TS1M0 | |
64-bit Enabled HP-UX | 9.2 TS1M0 | |
64-bit Enabled Solaris | 9.2 TS1M0 | |
HP-UX IPF | 9.2 TS1M0 | |
Linux | 9.2 TS1M0 | |
Linux for x64 | 9.2 TS1M0 | |
OpenVMS on HP Integrity | 9.2 TS1M0 | |
Solaris for x64 | 9.2 TS1M0 | |