有一个数据集,如下左图。
想做一个循环,首先判断x
,当x=1
时,则判断从x=1
的这行开始进行。
之后判断y
,如果y<9,
那么number
记录该行数值,t
记录‘ok’
;
如果y>=9
,那么判断下一行的y
值,直到y
值小于9
为止,此时number
记录行数,t
记录‘ok'
。
| x | y |  | x | y | number | t | 
| 7 | 3 |  | 7 | 3 |  |   | 
| 5 | 2 |  | 5 | 2 |  |   | 
| 3 | 9.2 |  | 3 | 9.2 |  |   | 
| 1 | 7 |  | 1 | 7 | 4 | ok | 
| 4 | 5 |  | 4 | 5 |  |   | 
| 4 | 4 |  | 4 | 4 |  |   | 
| 1 | 9.6 |  | 1 | 9.6 |  |   | 
| 3 | 9.7 |  | 3 | 9.7 |  |   | 
| 8 | 9.4 |  | 8 | 9.4 |  |   | 
| 2 | 3 |  | 2 | 3 | 10 | ok | 
| 7 | 2 |  | 7 | 2 |   |   | 
 
data a;
input x y @@;
cards;
7 3 5 2 3 9.2 1 7 4 5 4 4 1 9.6 3 9.7 8 9.4 2 3 7 2
;
run; 
data b;
set a (firstobs=1) nobs=n;
if _n_>1 then do;
   if x=1 then do;     
     if y<9 then do; number=_n_;t='ok';end;
       if y>=9 then do;
          do i=_n_+1;
          set a point=i;
          if y<9 then do; number=_n_;t='ok';     end; 
            else i=i+1;
       end;
      end;
      end;
end;
run;
 
请教一下,我的程序哪里出问题呢?无法得到上述右图的表格。谢谢