In the following data set I have three variables bad xx and yy.
I want to make histograms of XX and YY such that at each level of a variable say XX, I want to divide the column by proportion or percentage of bad=1 and bad=0.
My following attempts does this job but it divides each column by percentage of bad=0 and bad=1 w.r.t to all the values of XX.
For variable XX, I want bars of the histogram at 2,4,6,8 and 10, however division of each bar should be done based on the number of bad=1/bad=0 within that level of XX.
If this can be done, all the vertical bars will have equal height, but get divided by percentage/proportion of bad values within that level of XX.
Using the following code
I have this plot
As always, I am expecting some help from one of you experts.
Thanks again for your time!
You may be looking for G100 which requires use of Group not subgroup. Since you posted pictures of code and note code I'm too lazy to retype the data example so I can't test.
here is the code
Thanks
data have;
input Bad $ xx yy @@;
cards;
0 10 5
0 6 5
1 6 7
1 8 3
1 4 1
0 6 9
0 8 9
0 4 7
0 2 5
1 2 7
1 8 3
1 4 5
0 6 3
0 8 3
;
goptions reset=all;
proc gchart data=have;
vbar xx yy/type=percent
group=Bad;
run;
quit;
What version of SAS do you have? Can you use the SG graphical procedures, ie SGPLOT?
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.
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.