data have;
input ID year event ;
cards;
1 2014 0
1 2015 0
1 2016 1
2 2014 0
2 2015 1
2 2016 1
3 2014 1
3 2015 1
3 2016 1
;
run;
data want;
do until(last.id);
set have;
by id;
if event and not found then do;new_year=year;found=1;end;
end;
do until(last.id);
set have;
by id;
output;
end;
drop found;
run;
... View more