Comparing rows by variable HELP

Posts: 0

Comparing rows by variable HELP

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??
Super Contributor
Super Contributor
Posts: 366

Re: Comparing rows by variable HELP

Posted in reply to deleted_user
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;
1 Steve Old
4 Mike Old
2 Steve Old
6 Steve Old
7 Lisa New
3 Mike New
5 Mike New
8 Lisa New
proc sort data=b;
by name age;
data r;
retain t;
set b;
if then t=age;
if and t=age then output;
by name;
drop t;

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation