|
I think you need to outside = sum in the vbar options, i.e,
vbar visit / discrete
type=sum
sumvar=pcnt
subgroup = viscat
width=7
patternid=subgroup
outside = sum;
On Wed, Feb 11, 2009 at 10:16 PM, Anna Larbalestier
<anna.larbalestier@bristol.ac.uk> wrote:
> Hello there
>
> I am trying to create a bar chart of proportions with frequency counts
> on top. There is one bar for each visit. Each visit is categorised 1,
> 2 or 3. Each bar is subdivided into the proportions of categories 1, 2
> and 3. All bars add up to 100%. I would like to put on top of the bars
> a count of the number of observations that went into each bar. This is
> the bit I can't figure out how to do. My code is as follows:
>
> *** Get counts of visit by visit category ***;
> proc freq data = vis_count1 noprint;
> table visit*viscat / out = visfreq1 (drop=percent);
> run;
>
> *** Get counts of visit ***;
> proc freq data = vis_count1 noprint;
> table visit / out = visfreq2 (drop=percent rename = (count=vcount));
> run;
>
> *** Merge together and calculate % in each category at each visit ***;
> data visfreq;
> merge visfreq1
> visfreq2;
> by visit;
> pcnt = (count/vcount)*100;
> run;
>
> *** Produce bar chart ***;
> proc gchart data=visfreq;
> vbar visit / discrete
> type=sum
> sumvar=pcnt
> subgroup = viscat
> width=7
> patternid=subgroup;
> run;
> quit;
>
> Many thanks for your help
>
> Anna
>
|