BookmarkSubscribeRSS Feed
rnmishra
Calcite | Level 5

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!

3 REPLIES 3
ballardw
Super User

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.

rnmishra
Calcite | Level 5

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;

Reeza
Super User

What version of SAS do you have? Can you use the SG graphical procedures, ie SGPLOT?

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