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
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.