Hello all, I have been using SAS 9.4 for ~9 months. I am currently working with hospital discharge data and have run into a problem. I have individuals who are distinct, but do not have the same unique ID i.e., the same individual has more than one "unique" id. To correct this problem, I created a new unique id variable, and now want to assign that value to the all subsequent values (event =2 or 3) for the ID for each time an indivudal appears in the data. I have been trying to use the retain statement in my program, but can not get that to work. I want to end up with a dataset where I keep all rows, but where the newid variable is the same in rows where Last_name first_name are the same and takes the value when event=1 . The code I am using is below. Any help would be much appreciated!!!! proc sort data=dups1;
by last_name first_name birth_date ADMIT_START_OF_CARE s;
run;
DATA dups1;
SET dups1;
retain newid;
BY last_name first_name birth_date ADMIT_START_OF_CARE s;
if first.last_name then do;
event=1;
retain event;
end;
if first.last_name^=1 then event=event+1;
run;
DATA dups1;
SET dups1;
retain newid;
by last_name first_name birth_date event;
if last.event then do;
practiceid=newid;
end;
run;
... View more