Previous Page | Next Page

The GCHART Procedure

Example 5: Controlling Midpoints and Statistics in a Horizontal Bar Chart


Procedure features:

HBAR statement options:

AUTOREF

COUTLINE=

CLIPREF

SUBGROUP=

HBAR3D statement options:

FREQ

FREQLABEL=

MIDPOINTS=

Other features:

GOPTIONS statement option:

BORDER

AXIS statement

LEGEND statement

RUN-group processing

Sample library member: GCHBRMID

[untitled graphic]

This example uses the FITNESS data set to produce a horizontal bar chart that shows the number of people in each age group in a fitness program.

It charts the numeric variable AGE with the frequency statistic. Because the values of AGE are continuous, the procedure automatically divides the ages into ranges and displays the midpoint of each age range. The frequency statistic calculates the number of observations in each range. The chart statistic defaults to FREQ because the SUMVAR= and TYPE= options are omitted. The table of statistics displays all the statistic values.

The second part of this example modifies the midpoint axis and the table of statistics, and uses RUN-group processing to produce the following chart. This part of the program specifies the midpoint value for each bar and requests only the FREQ statistic for the table.

[GCHBRMID(b)-Controlling Statistics and Midpoints in a horizontal bar chart]

 Note about code
goptions reset=all border;
 Note about code
data fitness;
input age sex $ heart exer aero;
datalines;
28 M 86 2 36.6
41 M 76 3 26.7
30 M 78 2 33.8
29 M 54 3 44.8
48 F 66 2 28.9
36 F 66 2 33.2
;
 Note about code
title1 "Fitness Program Participants";
footnote j=r "GCHBRMID(a)";
 Note about code
axis1 label=("Number of People")
minor=(number=1)
offset=(0,0);
 Note about code
legend1 label=none
value=("Women" "Men");
 Note about code
wref=(5 5);
lref=(2 1);
 Note about code
proc gchart data=fitness;
hbar age / subgroup=sex legend=legend1 autoref
     clipref
     raxis=axis1;
run;
 Note about code
axis1 order=(0 to 4 by 1)
label=("Number of People")
minor=(number=1)
offset=(0,0);
 Note about code
footnote j=r "GCHBRMID(b)";
 Note about code
axis2 label=("Age " j=r "Group");
 Note about code
hbar3d age / midpoints=(30 40 50)
freq freqlabel="Total in Group" subgroup=sex autoref
     maxis=axis2
     raxis=axis1
     legend=legend1
     coutline=black
     ;
run;
quit;

Previous Page | Next Page | Top of Page