Chapter Contents

Previous

Next
The GCHART Procedure

Example 3: Specifying the Sum Statistic in Bar Charts


Procedure features:
HBAR statement options:
SUMVAR=
VBAR3D statement options:
SUMVAR=
COUTLINE=
Other features:
FORMAT statement
PATTERN statement
RUN-group processing
Data set: TOTALS
Sample library member: GR13N03

[IMAGE]

This example produces two bar charts that show total sales for three sites by charting the values of the character variable SITE and calculating the sum of the variable SALES for each site.

In the horizontal bar chart shown above, the summary statistics are printed by default to the right of the bars and display the formatted values of SALES.

The bars use the default pattern fill, which is solid. Because a colors list is specified in the GOPTIONS statement, the first default pattern color is the first color in the list. To avoid having black bars, the program uses a PATTERN statement to specify the pattern color. Using a PATTERN statement causes the default bar outline color to match the fill color. All the bars display the same pattern because by default patterns change for subgroups and in this chart subgroups are not specified.

The output also shows the frame that is drawn by default around the axis area.

The second bar chart is a 3D vertical bar chart, shown in the following output. Vertical bar charts do not generate a table of statistics and by default do not print any chart statistics. This chart uses the same pattern as the horizontal bar chart, but the VBAR3D statement specifies a black outline for the bars.

[IMAGE]

 Note about code
libname reflib 'SAS-data-library';
goptions reset=global gunit=pct border
         colors=(black red blue green)
         cback=white ftitle=swissb ftext=swiss
         htitle=6 htext=3.5;
 Note about code
title1 'Total Sales';
footnote1 h=3 j=r 'GR13N03(a) ';
 Note about code
pattern1 color=red;
 Note about code
proc gchart data=reflib.totals;
   format sales dollar8.;
   hbar site / sumvar=sales;
run;
 Note about code
   footnote1 h=3 j=r 'GR13N03(b) ';
   vbar3d site / sumvar=sales
                 coutline=black;
run;
quit;


Chapter Contents

Previous

Next

Top of Page

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