32# tagv
data a;
do time_record=1 to 1000;
output;
end;
run;
%macro RMrecords(s=5);*s should be an integer;
%local i;%let i=1;
proc sort data=a out=As nodupkey; by Time_record; run;
%do%while(&i le &s.);
data As;
set As;
retain s 0;
m=dif(Time_record);
if missing(m) or m>5 then m=0;
if m then s+m; else s=0;
if ^s or s>5 ;*keep those s>5,保证正确地的删除;
drop m s;
run;
data final;
set As;
lagTradeTime=dif(Time_record);
run;
proc sql noprint;
select min(lagTradeTime) into :i from Final;
quit; *不断地估计i,保证循环;
%put &i;
%end;
%mend RMrecords;
%RMrecords
;
proc print;run;
从sushe的程序而来 这个应该有效些;