data a;
set test;
rename x=x_a;
run;
data b;
set test;
rename x=x_b;
run;
proc sort data =a ;
by y;
run;
proc sort data =b;
by y;
run;
data test_a ;
merge a (in =a) b (in =b);
by y ;
if (a =1);
if x_a < x_b;
run;
貌似少了一条记录,改了下,哈哈
data final(drop=x);
if 0 then set test;
if _n_ = 1 then do;
dcl hash h(dataset:'test',multidata:'y');
h.definekey('y');
h.definedata(all:'y');
h.definedone();
end;
set test;
x_a = x;
if ~h.find() then do;
if x_a < x then do;
x_b = x;
output;
end;
do while(~h.find_next() );
x_b = x;
if x_a < x_b then output;
end;
end;
run;