BookmarkSubscribeRSS Feed
braam
Quartz | Level 8

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!

4 REPLIES 4
braam
Quartz | Level 8

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.

 

Ksharp
Super User

You mean this ?

 

proc sgplot  data=sashelp.class;
hbar sex/datalabel stat=percent;
run;
DanH_sas
SAS Super FREQ

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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 821 views
  • 1 like
  • 4 in conversation