Okay, you've tried. Fair enough. ;D
data OUT (drop = _:); /* drop old vars */
set IN (rename = (ADMISSION1=_A1 ADMISSION2=_A2 ADMISSION3=_A3));
by PERSON; /* input dataset MUST BE sorted by PERSON */
retain ADMISSION1 '' ADMISSION2 '' ADMISSION3 ''; /* new vars */
/* reset _A* vars for each PERSON group start */
if first.PERSON then do;
ADMISSION1=''; ADMISSION2=''; ADMISSION3='';
end;
/* coalescec returns the first non empty value of a list */
ADMISSION1=coalescec(_A1,ADMISSION1);
ADMISSION2=coalescec(_A2,ADMISSION2);
ADMISSION3=coalescec(_A3,ADMISSION3);
/* output last record only */
if last.PERSON;
run;
Now, in the above solution, new ADMISSION vars are created (retained) based on the old ones, which will be dropped at the end of the datastep.
At each group start, new vars are reset to '', and for each group row, the result of the coalescec function is assigned (coalescec function returns the first non empty value of a list). Finally, and since you need only row per group, output to the dataset is perform only at the last row of the group.
Cheers from Portugal.
Daniel Santos @
www.cgd.pt.