BookmarkSubscribeRSS Feed
ABanker
Calcite | Level 5


I want to use proc tabluate to make a cross tab of bad rates using a variable bad that is 1 if the observation is bad and 0 otherwise.  My sample code is attached. As I see the main issue, I want to treat bad as a class and analysis variable in order to get the sum of the bads and divide by the number of observations.  I know I can't do that.  I'm sure there is a very elegant way to do this.  Many thanks for people's time!

Teresa

2 REPLIES 2
Astounding
PROC Star

You are not the first person trying to do this the hard way.  With a 0/1 variable, make it an analysis variable and calculate the mean.  That's the same as the sum of the "bads" divided by the number of observations.

Good luck.

ballardw
Super User

Adding to Astounding note, and N gives number of records considered and Sum yields number of bad. I use this approach a lot as my customers will almost always ask something like "How many bad?" or "How many records?" when seeing 0 or 100 percent, or some value above/below a theshold of interest, for some group. It heads off follow-up request to provide all 3 up front.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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