Sample 69819: Using the SGPLOT procedure with the VBAR and VLINE statements to create a bar chart with line overlay
This SAS Note provides a sample of how to use the SGPLOT procedure with the VBAR and VLINE statements to overlay individual plot lines on a bar chart.
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 code uses the SGPLOT procedure with the VBAR and VLINE statements to overlay individual plot lines on a bar chart.
/* Creates sample data for product sales */
data barline;
input Year Desk Chair Sofa Lamp Table;
format Desk Chair Sofa Lamp Table dollar.;
datalines;
2008 20000 15000 12000 3000 11000
2009 21000 16000 14000 4000 12000
2010 22000 16500 14500 4200 12500
2011 21000 15500 13500 3500 11700
2012 20000 15000 13000 2500 12000
;
run;
ods graphics / reset width=6in height=4in imagename="BarlinePlot";
title 'Sales by Product and Year';
/* Create a bar line plot */
proc sgplot data=barline;
vbar year / response=desk stat=sum dataskin=sheen nostatlabel name='a';
vline year / response=chair stat=sum lineattrs=(thickness=9 pattern=solid) nostatlabel curvelabel;
vline year / response=sofa stat=sum lineattrs=(thickness=9 pattern=solid) nostatlabel curvelabel;
vline year / response=lamp stat=sum lineattrs=(thickness=9 pattern=solid) nostatlabel curvelabel;
vline year / response=table stat=sum lineattrs=(thickness=9 pattern=solid) nostatlabel curvelabel;
keylegend 'a' / location=inside position=topright;
xaxis display=(nolabel);
yaxis grid offsetmin=0 display=(nolabel);
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.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> SGPLOT
|
Date Modified: | 2023-01-31 13:27:16 |
Date Created: | 2023-01-20 13:00:31 |
Operating System and Release Information
SAS System | Base SAS | Solaris for x64 | 9.4 | | 9.4 TS1M0 | |
Linux for x64 | 9.4 | | 9.4 TS1M0 | |
HP-UX IPF | 9.4 | | 9.4 TS1M0 | |
64-bit Enabled Solaris | 9.4 | | 9.4 TS1M0 | |
64-bit Enabled AIX | 9.4 | | 9.4 TS1M0 | |
Windows 7 Professional x64 | 9.4 | | 9.4 TS1M0 | |
Windows 7 Enterprise x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2012 Std | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2012 R2 Std | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2012 R2 Datacenter | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2012 Datacenter | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2008 for x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2008 R2 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 10 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8.1 Pro x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8.1 Pro 32-bit | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8.1 Enterprise x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8.1 Enterprise 32-bit | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8 Pro x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8 Enterprise x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft® Windows® for x64 | 9.4 | | 9.4 TS1M0 | |
z/OS 64-bit | 9.4 | | 9.4 TS1M0 | |
z/OS | 9.4 | | 9.4 TS1M0 | |