Sample 25512: Midpoints/stats in horizontal bar chart using PROC GCHART
This sample is from the "SAS/GRAPH Software: Reference, Version 8", Volume 1, Chapter 13.
For additional information on the sample refer to this book.
/*+------------------------------------------------------+
| S A S S A M P L E L I B R A R Y |
| |
| NAME: GCHBRMID |
| TITLE: GCHBRMID-Midpoints/Stats in Horiz Bar Chart |
| PRODUCT: GRAPH |
| SYSTEM: ALL |
| KEYS: GRAPHICS GCHART AXIS PATTERN LEGEND |
| PROCS: GCHART |
| DATA: INTERNAL |
| |
| SUPPORT: GRAPHICS STAFF UPDATE: |
| REF: SAS/GRAPH REFERENCE GUIDE |
+------------------------------------------------------+*/
goptions reset=all gunit=pct border cback=white
colors=(black blue green red) ftitle=swissb
ftext=swiss htitle=6 htext=3.5;
/* Create the FITNESS data set */
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
39 F 90 1 13.6
28 M 96 1 33.
26 M 74 2 42.7
. F 66 4 36.1
48 F 72 2 22.6
31 M 60 3 44.1
28 F 84 2 22.1
33 F 56 4 21.3
37 F 78 2 30.3
46 M 84 1 34.2
23 M 72 2 38.1
25 F 88 1 32.0
37 F 72 2 43.7
42 M 60 3 36.7
44 F 78 3 21.6
. F 70 1 22.8
25 F 60 3 36.1
24 F 74 2 29.9
29 F 66 4 38.9
27 M 62 4 44.0
24 M 72 3 44.2
36 F 80 1 26.2
24 M 82 2 18.7
23 M 54 3 70.6
28 F 76 1 23.8
30 F 66 2 28.9
25 M 54 3 41.3
48 F 72 2 28.9
23 F 68 1 18.9
22 F 78 2 39.0
23 F 66 3 36.1
46 F 54 3 28.9
31 F 84 1 21.6
45 M 60 2 47.8
27 M 90 2 43.1
26 M 66 2 28.9
26 F 84 2 .
24 M 72 3 50.1
32 F 72 1 15.7
29 M 54 3 44.8
48 F 66 2 28.9
36 F 66 2 33.2
;
/* Define title */
title1 'Fitness Program Participants';
footnote1 h=3 j=r 'GCHBRMID(a) ';
/* Define response axis characteristics */
axis1 label=('Number of People')
minor=(number=1)
offset=(0,0);
/* Define legend characteristics */
legend1 label=none
value=('Women' 'Men');
/* Define pattern colors */
pattern1 color=cyan;
pattern2 color=blue;
/* Chart the values of AGE */
proc gchart data=fitness;
hbar age / subgroup=sex
legend=legend1
autoref
clipref
coutline=black
raxis=axis1;
run;
/* Create chart with modified midpoints */
footnote h=3 j=r 'GCHBRMID(b) ';
/* Add order= to response axis */
axis1 order=(0 to 20 by 2)
label=('Number of People')
minor=(number=1)
offset=(0,0);
/* Modify midpoint axis label*/
axis2 label=('Age' j=r 'Group');
/* Create chart */
hbar3d age / midpoints=(20 30 40 50)
freq
freqlabel='Total in Group'
subgroup=sex
autoref
maxis=axis2
raxis=axis1
legend=legend1
coutline=black
cframe=grayaa;
run;
quit;

This example produces a horizontal bar chart with descriptive statistic values printed in a table to the right of the bar chart.
| Type: | Sample |
| Topic: | Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Charts ==> Bar SAS Reference ==> Procedures ==> GCHART
|
| Date Modified: | 2005-08-13 03:02:43 |
| Date Created: | 2005-05-23 14:12:24 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | 8 TS M0 | n/a |