The sample code on the Full Code tab illustrates how to use an annotate data set to place response values at the end of each bar on a horizontal bar chart created with the GCHART procedure and how to accomplish the same results with the DATALABEL option on an HBAR statement in the SGPLOT procedure.
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.
/* Set the graphics environment */
goptions reset=all border cback=white htext=10pt htitle=12pt;
/* Create data set A */
data a;
input midvar $ 1-21 respvar;
datalines;
Accuracy of Order 95
Overall for Breakfast 80
Overall for Lunch 85
Temperature of Food 78
Value for the Money 87
;
run;
/* Create an annotate data set to place the */
/* response value at the end of each bar. */
data annobars;
length function color $8 text $3;
retain xsys ysys '2' when 'a';
set a;
function='label';
midpoint=midvar;
x=respvar;
position='>'; /* left-align the text */
text=respvar;
output;
run;
/* Specify axis characteristics */
axis1 label=none;
axis2 label=('Response values');
/* Add a title to the graph */
title1 'Survey Results';
/* Create the graph */
proc gchart data=a;
hbar midvar / maxis=axis1 raxis=axis2 nostats
sumvar=respvar annotate=annobars;
run;
quit;
/* Use the SGPLOT procedure to create the graph without annotation */
proc sgplot data=a;
hbar midvar / response=respvar datalabel;
yaxis display=(nolabel);
xaxis label='Response values';
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 ==> GCHART Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Elements ==> Annotation Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Charts ==> Bar |
Date Modified: | 2021-03-02 15:28:45 |
Date Created: | 2014-02-28 14:36:43 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS/GRAPH | z/OS | 9.1 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M0 | |||
Microsoft Windows 2000 Advanced Server | 9.1 TS1M0 | |||
Microsoft Windows 2000 Datacenter Server | 9.1 TS1M0 | |||
Microsoft Windows 2000 Server | 9.1 TS1M0 | |||
Microsoft Windows 2000 Professional | 9.1 TS1M0 | |||
Microsoft Windows NT Workstation | 9.1 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M0 | |||
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M0 | |||
Microsoft Windows XP Professional | 9.1 TS1M0 | |||
64-bit Enabled AIX | 9.1 TS1M0 | |||
64-bit Enabled HP-UX | 9.1 TS1M0 | |||
64-bit Enabled Solaris | 9.1 TS1M0 | |||
HP-UX IPF | 9.1 TS1M0 | |||
Linux | 9.1 TS1M0 | |||
OpenVMS Alpha | 9.1 TS1M0 | |||
Tru64 UNIX | 9.1 TS1M0 |