Data visualization with SAS programming

change yaxis in sgplot vbar

Reply
Contributor
Posts: 48

change yaxis in sgplot vbar

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

 

SAS Super FREQ
Posts: 3,231

Re: change yaxis in sgplot vbar

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.

 

Contributor
Posts: 48

Re: change yaxis in sgplot vbar

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

SAS Super FREQ
Posts: 864

Re: change yaxis in sgplot vbar

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

 

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

SAS Super FREQ
Posts: 864

Re: change yaxis in sgplot vbar

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

Contributor
Posts: 48

Re: change yaxis in sgplot vbar

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

 

Thanks,
chen

Post a Question
Discussion Stats
  • 5 replies
  • 98 views
  • 0 likes
  • 3 in conversation