data t2;
do i=1 by 1 until(last.x);
set t1;
by x notsorted;
if first.x then cnt=0;
cnt+1;
end;
do i=0 by 1 until(last.x);
set t1;
by x notsorted;
x_old=x;
if cnt>=3 then x=.;
output;
end;
keep x x_old;
run;
honghejing 发表于 2011-8-22 16:56
data a;
input a;
n=_n_;
The result is not EXACT what he wanted. I believe it is not quite easy to use SQL solving this problem because SQL is not designed to handle data sequentially.