data have;
input ID $ JOB $ as ;
cards;
A-0-0082 X 25
A-0-0082 Y 25 yes
A-0-0082 Z 25
A-0-0111 Y 36 no
A-0-0111 C 36 no
B-0-0012 D 20 no
B-0-0012 Y . yes
B-0-0012 Y 40 no
;
run;
data temp;
set have;
by id job notsorted;
group+first.job;
run;
data want;
set temp;
by group;
if last.group and job='Y';
run;