data ds1;
input sbdv num loc;
datalines;
150 0.876 1
160 0.993 1
171 0.937 1
;
data ds2;
input _sbdv _num _loc;
datalines;
120 0.987 0
121 0.965 0
123 0.945 0
125 0.912 0
;
data want;
if _n_=1 then do;
if 0 then set ds2;
declare hash h(dataset:'ds2');
declare hiter hi('h');
h.definekey('_sbdv');
h.definedata(all:'y');
h.definedone();
end;
set ds1;
min=999999;
do while(hi.next()=0);
dis=abs(num-_num);
if dis<min then do;min=dis;sbdv1=_sbdv;num1=_num;loc1=_loc;end;
end;
h.remove(key:sbdv1);
drop _: min dis;
run;
... View more