BookmarkSubscribeRSS Feed
the_sheriff
Calcite | Level 5

Hello,

 

i have data with three variables, hospital, patient, and bad_event.  My desired result is a proc report table with hospital, N, and count of bad events.

 

the data looks like this

A 001 0

B 002 0

C 003 0

A 004 1

B 005 1

C 006 0

A 007 0

B 008 1

C 009 0

if i use the code below i get exactly what i want because the values for bad_event are 1 and 0. 

 

proc report data=test;
columns hospital n bad_event=bad_event_sum;
define hospital/ group;
define n / format=8.;
define bad_event_sum/ sum;
run;

 

My question is, instead of summing all of the bad_event values (ones and zeros), can i count all of the values that are not zero (for example)? i am asking because it is entirely possible that i will be given data where the values of bad_event will be, for example, 0,1,2,3,4. And in this case using sum will not work.


Thank you for any help that you can provide.

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Do it in a datastep or procedure before hand, then use proc report as a reporting procedure only.  I never use a reporting procedure to do data manipulation.

Ksharp
Super User

NO. I is hard for proc report.

process the dataset firstly(add a new variable):

 

new_bad_event=ifn(bad_event=0,0,1);

 

After that run your code again ,using new_bad_event variable.

 

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