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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.