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 2024

Innovate_SAS_Blue.png

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. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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