Sample 24887: Annotate values for each subgroup bar with PROC GCHART
While you can use the INSIDE and OUTSIDE options on the VBAR statement of GCHART to display the percentage values within each subgroup, this sample demonstrates how to label the subgroups with the Annotate facility.
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.
While you can use the INSIDE and OUTSIDE options on the VBAR statement of GCHART to display the percentage values within each subgroup, this sample demonstrates how to label the subgroups with the Annotate facility.
The graphics output in the Results tab was produced using SASĀ® 9.2. Submitting the sample code with releases of SAS prior to SAS 9.2 might produce different results.
/* Set the graphics environment */
goptions reset=all cback=white border
htitle=12pt htext=10pt;
/* Create input data set SOLD */
data sold;
input City $ Sales comma7. Type $;
datalines;
Atlanta 200,175 Inside
Atlanta 100,100 Outside
Chicago 425,500 Inside
Chicago 322,010 Outside
Seattle 308,110 Inside
Seattle 100,355 Outside
;
run;
/* Create the Annotate data set ANNO */
data anno;
length function color text $ 8 style $ 20;
retain function 'label' color 'black' when 'a'
xsys ysys '2' position 'E' size 3 hsys '3';
set sold;
style="'Albany AMT'";
midpoint=city;
subgroup=type;
text=left(put(sales,dollar8.));
run;
/* Define axis characteristics */
axis1 minor=none label=('Sales');
/* Add a title to the graph */
title 'Sales Report';
/* Produce the bar chart using the ANNO= */
/* option on the VBAR statement. */
proc gchart data=sold;
vbar city / sumvar=sales raxis=axis1
nozero anno=anno subgroup=type
width=12 space=3;
format sales dollar8.;
run;
quit;
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.
While you can use the INSIDE and OUTSIDE options on the VBAR statement of GCHART to display the percentage values within each subgroup, this sample demonstrates how to label the subgroups with the Annotate facility.
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: | 2005-08-24 16:06:29 |
Date Created: | 2004-11-11 11:07:55 |
Operating System and Release Information
SAS System | SAS/GRAPH | All | n/a | n/a |