For completenes.. If the range of DINs is somewhat sparse, this should be quite fast as well...
data din;
input din;
datalines;
812463
824216
851752
851760
851841
;
data have;
input din v;
datalines;
812463 1
123456 2
824216 3
234567 4
851752 5
345678 6
851760 7
456789 8
851841 9
;
data want;
array d {0 : 999999} _temporary_;
do until (z1);
set din end = z1;
d[din] = 1;
end;
do until (z2);
set have end = z2;
if d[din] then output;
end;
run;
... View more