A handy DATA step technique is to go through the data twice:
data want;
length first_date $ 10;
do until (last.ID);
set have;
by id;
if first_date=' ' and stat in ('9', 'F', 'R') then first_date=date;
end;
do until (last.ID);
set have;
by id;
output;
end;
run;
This version assumes DATE is character, but if it's numeric just change the LENGTH statement (and the check for first_date=' ').
Good luck.
... View more