Reputation: 333
I have a table with identifier for people and this identifier is not unique. Some people from the same family will have the same identifier, and each family will have one core member (there is another column telling if he his the core member or not). I would like to add to this table a column with the age of the core member from the family of the line.
In order to do this in Excel, I would use a VLookUp on the table, but I can't figure how to do it using SAS.
I tried to search for help on this subject but it seems that a lot of the answer given are to merge the table, but I don't feel that it can be done here.
Thanks!
Upvotes: 0
Views: 566
Reputation: 1283
Why not? Assuming that there is only 1 core member per ID:
proc sort data=PEOPLE;
by identifier;
run;
data PEOPLE (drop=is_core_member);
merge PEOPLE PEOPLE (keep=identifier core_member age rename=(core_member=is_core_member age=core_member_age) where=(is_core_member=1));
by identifier;
run;
Note that the keep and rename are necessary to avoid common variable names between the tables (besides the identifier). The drop is for keeping the result clean.
Sometimes it pays to test feelings. ;)
Upvotes: 1