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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 857 views
  • 0 likes
  • 2 in conversation