BookmarkSubscribeRSS Feed
echoli
Obsidian | Level 7

Hi All,

 

How can I change yaxis in the vbar figure? I don't need frequency, I need percentage. But I don't have a percentage column in dataset, I can got it by proc freq.

here is my code for figure:

 

proc freq data=lin_;
tables binary*groups;
run;

 

proc sgplot data=lin_;
vbar binary / group = groups groupdisplay = cluster;
run;

 

any idea?

 

Thanks,

Chen

vbar.png

 

5 REPLIES 5
Rick_SAS
SAS Super FREQ

Here is a link to the doc for the VBAR statement.  If you search for "percent" on that page you will find the STAT=PERCENT option.

 

echoli
Obsidian | Level 7

Hi Rich,

 

I tried to use stat=percent option, but what if I just want col percent for Y axis? Any way to solve this?

 

Thanks,

Chen

DanH_sas
SAS Super FREQ

If you have a column called "percent", do this instead:

 

proc sgplot data=lin_;
vbarparm  x=binary y=percent / group = groups groupdisplay = cluster;
run;

DanH_sas
SAS Super FREQ

If you use STAT=PCT on the VBAR statement, do you get what you want?

echoli
Obsidian | Level 7

I got group percentage, but I just want col percentage in Y axis.

 

Thanks,
chen

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

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
  • 5 replies
  • 2603 views
  • 0 likes
  • 3 in conversation