- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Dear SAS Community,
I was hoping to label each category in the bars with the respective percentage, but instead I am getting these numbers. According to the freq table, for the season=2024 the percentage for Hass should be 95% for PeelColor=4 so I wonder what '152' means (green color last column on the right). I would greatly appreciate your help!
This is the code I am using :
title "100 Stacked Bar Chart Ordered by Percentages";
proc sgpanel data=one ;
where Variety in('BL516', 'Hass');
panelby Season / columns=4 one panel;
vbar Variety / response=PeelColor group=PeelColor
grouporder=data groupdisplay=stack seglabel ;
colaxis discreteorder=data;
rowaxis grid values=(0 to 100 by 10) label="Percentage of PeelColor category";
run;
|
|
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ha. You need another option PCTLEVEL= too.
proc sgpanel data=sashelp.heart pctlevel=group; panelby status / columns=2 onepanel; vbar bp_status / response=weight group=sex grouporder=data groupdisplay=stack seglabel stat=percent ; colaxis discreteorder=data; run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What is 4*38? 152.
Look at the STAT= option of VBAR. It is SUMming the values of Peelcolor value by default.
Try STAT=PERCENT.
HINT: Almost all the categorization plots are going to default to a FREQ (count) or SUM of sort.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Oh that's right, thank you very much for the clarification.
I tried this code including stat=percent and I think this graph makes more sense to me:
proc sgpanel data=one ;
where Variety in('BL516','Hass');
panelby Season / columns=4 onepanel;
vbar Variety / group=PeelColor stat=percent
groupdisplay=stack seglabel /*seglabelattrs=(size=12 color=white)*/;
run;
The percentages labeled are total percentages from all seasons.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ha. You need another option PCTLEVEL= too.
proc sgpanel data=sashelp.heart pctlevel=group; panelby status / columns=2 onepanel; vbar bp_status / response=weight group=sex grouporder=data groupdisplay=stack seglabel stat=percent ; colaxis discreteorder=data; run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much Ksharp, thats exactly what I wanted!