Dear All,
I would like to add % in my proc sgplot hbar. I managed to display the actual frequency by datalabel option, but don't know how to show its percentage. Any good idea?
Any procedures to display a looking-good graph with % would be good for me as well.
proc sgplot data= tcult.set4; hbar group /datalabel; run;
Thanks in advance!
Thanks. My graph looks like the last one in the blog you mentioned. But I would like to add % at the right of the graph.
You mean this ?
proc sgplot data=sashelp.class;
hbar sex/datalabel stat=percent;
run;
If you want to show just percentage in the graph, you can do what @Ksharp said (with one additional option for right positioning):
proc sgplot data=sashelp.class;
hbar sex / datalabel stat=percent datalabelpos=right;
run;
If you want the bar chart to still show frequency, but also show percentages, do this:
proc sgplot data=sashelp.class;
hbar sex;
yaxistable sex / stat=percent;
run;
Hope this helps!
Dan
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.