- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'd like to display on a single plot using vbar or similar labeling with both percentage and frequency count displayed. I use sas 9.4.
Code I have is:
proc sgplot data=have noborder;
yaxis label= "Counts";
vbar var/GROUPORDER=ascending stat=percent datalabel;
run;
How can I modify it to add counts?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
See if this will work for you:
proc sgplot data=sashelp.class noborder;
yaxis label= "Counts";
vbar age/GROUPORDER=ascending stat=percent datalabel;
xaxistable age / location=inside stat=freq;
run;
Hope this helps!
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I tried it and it duplicated the items on the x-axis and did not add a percentage.
capam
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I get the percent labels on the bars and the freq values in the axis table. What version of SAS 9.4 do you have? Please run this and let me know what the log says:
%put &sysvlong;
Thanks!
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
9.04.01M3P062415
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In the example, the freq values are along the bottom of the bars. I get this with 9.4m3 as well: They can be also moved to the top of the graph.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In that case, just add LABEL="Frequency" to the XAXISTABLE statement (after the "/").
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Or, are you saying that it just repeats 11, 12 13, 14, 15, and 16?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Try this and see if it works for you:
In a small datastep, copy your category column to another column (such as age2, in this example.) Use age2 in the XAXISTABLE instead.
data class;
set sashelp.class;
age2=age;
run;
proc sgplot data=sashelp.class noborder;
yaxis label= "Counts";
vbar age/GROUPORDER=ascending stat=percent datalabel;
xaxistable age2 / location=inside stat=freq label="Frequency";
run;