fanzai1hao 发表于 2015-4-7 16:29 
那如果下一个值为10继续跳过,再跳到直到下一个值不为10的观测,该怎么写呢,现在不可能把观测为10的数据 ...
data test1;
set test;
retain flg;
if price=10 and lag(price) ne 10 then do;
cnt1+1;
flg=0;
end;
if price not in (10 .) then do;
if flg=0 then cnt2+1;
flg+1;
end;
run;
proc sql noprint;
create table want as
select a.*, c.date as next_date
from test a left join
(select * from test1 where price=10) b
on a.date=b.date and a.price=b.price
left join
(select * from test1 where flg=1) c
on b.cnt1=c.cnt2
order by date;
quit;