Sample 69822: Creating a bar chart with confidence limits using the PROC SGPLOT HBAR statement and HBARPARM statement
This SAS Note provides a sample on how to use the PROC SGPLOT HBAR statement to add limits to a chart or the HBARPARM statement to add calculated limits to a horizontal 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 PROC SGPLOT HBAR statement to add limits to a chart or the HBARPARM statement to add calculated limits to a horizontal bar chart.
/* Sample 1: Create a horiztonal bar chart with limits calculated within the SGPLOT procedure */
title "Mileage by Type";
proc sgplot data=sashelp.cars noautolegend;
/* Generate a horizontal bar chart for average mileage in city driving
using the LIMITS= option to calculate and add lower and upper limits */
hbar type / response=mpg_city stat=mean limits=both
fillattrs=(color=cxa6bddb) limitattrs=(color=black);
yaxis display=(nolabel) grid;
xaxis display=(nolabel);
run;
/* Sample 2: Create a horiztonal bar chart with limits calculated prior to the SGPLOT procedure */
/* Use the MEANS procedure to calculate upper and lower limits */
proc means data=sashelp.cars alpha=.05 clm mean std noprint;
class type;
var mpg_city;
output out=carsMean uclm=uclm lclm=lclm mean=mean;
run;
title 'Mileage by Type';
proc sgplot data=carsMean;
/* Generate a horizontal bar chart for average mileage in city driving
using calculated limits */
hbarparm category=type response=mean /
fillattrs=(color=cxa6bddb)
limitlower=lclm limitupper=uclm
limitattrs=(color=black);
yaxis display=(nolabel) grid;
xaxis 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:31:27 |
Date Created: | 2023-01-20 15:08:47 |
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.4 | | 9.4 TS1M0 | |
z/OS 64-bit | 9.4 | | 9.4 TS1M0 | |
Microsoft® Windows® for x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8 Enterprise x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8 Pro x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8.1 Enterprise 32-bit | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8.1 Enterprise x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8.1 Pro 32-bit | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8.1 Pro x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 10 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2008 R2 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2008 for x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2012 Datacenter | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2012 R2 Datacenter | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2012 R2 Std | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2012 Std | 9.4 | | 9.4 TS1M0 | |
Windows 7 Enterprise x64 | 9.4 | | 9.4 TS1M0 | |
Windows 7 Professional x64 | 9.4 | | 9.4 TS1M0 | |
64-bit Enabled AIX | 9.4 | | 9.4 TS1M0 | |
64-bit Enabled Solaris | 9.4 | | 9.4 TS1M0 | |
HP-UX IPF | 9.4 | | 9.4 TS1M0 | |
Linux for x64 | 9.4 | | 9.4 TS1M0 | |
Solaris for x64 | 9.4 | | 9.4 TS1M0 | |