data have;
input ID Flag;
datalines;
1000 2
1000 1
1000 9
1000 1
1000 5
1000 1
1000 1
1000 1
1000 1
2000 11
2000 12
2000 4
2000 1
2000 1
2000 3
2000 1
2000 1
2000 1
;
run;
data want;
do until(last.flag);
set have;
by id flag notsorted;
if last.id then found=1;
end;
do until(last.flag);
set have;
by id flag notsorted;
if found and flag=1 then output;
end;
drop found;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Registration is open
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss. Register now and lock in 2025 pricing—just $495!