BookmarkSubscribeRSS Feed
Whitlea
Obsidian | Level 7

SAS v 9.3

I am trying to generate a simple sgplot with percentages.  I want to be able to add multiple variables on the vbar statement but that is not an option. I have I am also having trouble creating a data set from my proc freq that includes ALL of my variables. 

data work.ins15;

set ins.ins15;

run;

 

proc freq data=work.ins15;

tables cig ecig chew / plots=FreqPlot(scale=Percent) out=Freq1Out; /* save Percent variable */

weight _cpwt;

where cig=1 and ecig=1 and chew=1;

run;

data Freq1Out;

set Freq1Out ;

Percent = Percent / 100; /* adjust range to [0, 1] */

format Percent PERCENT5.;

run;

title "";

proc sgplot data=Freq1Out noborder;

vbar cig / response=Percent datalabel

fillattrs=(color=blue); /* axis shows percentages instead of counts */

xaxis display=(nolabel);

yaxis display=(nolabel) ;

run;

1 REPLY 1
pink_poodle
Barite | Level 11

For outputting multiple variables in frequency tables, please use multiple table statements. Similarly, to add multiple variables on a vertical bar graph, please try using multiple vbar statements. Please see also this post:

https://communities.sas.com/t5/Graphics-Programming/sgplot-with-Multiple-variables-on-vbar/td-p/3887...

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 1 reply
  • 2985 views
  • 1 like
  • 2 in conversation