BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I am trying to analyze some data on blood unit age and usage, and am having problems figuring out the code for what I want to do!

I have Blood unit number, Patients name, the age of the RBC unit

Some people got more than one unit.There names are duplicated each time they receive a unit of blood, beside that new units number. So some people have their names entered more than once.
Because I am analyzing this by age of unit, I want to exclude people that received more than one unit of blood with different ages (ie its ok if they got two units that are both 'new' but not ok if they got one that is 'new' and one that is 'old', I want to delete them)
I want to create a variable that is '1' for people with blood all of the same age, 0 for those that received mixed blood.

Any ideas??
1 REPLY 1
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Rfergs,

I am not sure that understood what you really need. I mean do you want to exclude some observations or simply mark them with 1 or 0? Anyway this how to exclude them:

data b;
input bu 1-2 Name $ 3-10 Age $ 11-13;
datalines;
1 Steve Old
4 Mike Old
2 Steve Old
6 Steve Old
7 Lisa New
3 Mike New
5 Mike New
8 Lisa New
;
run;
proc sort data=b;
by name age;
run;
data r;
retain t;
set b;
if first.name then t=age;
if last.name and t=age then output;
by name;
drop t;
run;

Sincerely,
SPR

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!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

Discussion stats
  • 1 reply
  • 831 views
  • 0 likes
  • 2 in conversation