Chapter Contents

Previous

Next
SAS/GRAPH Software: Reference

Example 2: Labeling Subgroups in a Vertical Bar Chart

Features:
Annotate function: LABEL (default)
Annotate variables: MIDPOINT
POSITION
SUBGROUP
Sample library member: GR10N02

[IMAGE]

This example shows how to label subgroups in a vertical bar chart that is generated by the GCHART procedure. Each bar represents total orders for a city and is subgrouped by the type of order. The Annotate facility labels each subgroup with the number of orders for that category. The coordinates that position the subgroup labels are derived from the values of the GCHART procedure variables CITY (the chart (or midpoint) variable) and TYPE (the subgroup variable). These variables are assigned to the corresponding Annotate variable.

See The GCHART Procedure for more information on creating bar charts.
 Note about code
libname reflib 'SAS-data-library';
goptions reset=global gunit=pct border cback=white
         colors=(blue green red) ctext=black htitle=6
         ftitle=swissb htext=4 ftext=swiss;
 Note about code
data sold;
   length type $ 10;
   input city $ units type $ ;
   datalines;
Atlanta  99 Printers
Atlanta 105 Plotters
...more data lines...
Sydney  136 Plotters
Sydney  100 Terminals
;
run;
 Note about code
data barlabel;
   length color style $ 8;
   retain color 'white' when 'a' style 'swissb'
      xsys ysys '2' position 'E' size 4 hsys '3';
   set sold;
   midpoint=city;
   subgroup=type;
   text=left(put(units,5.));
run;
 Note about code
title 'Orders Received';
footnote h=3 j=r 'GR10N02 ';
 Note about code
axis1 label=none major=none minor=none style=0
      value=none;
axis2 label=none;
 Note about code
proc gchart data=sold;
   vbar city / type=sum
               sumvar=units
               subgroup=type
               width=17
               raxis=axis1
               maxis=axis2
               annotate=barlabel;
run;
quit;


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.