想做一个循环,首先判断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;
请教一下,我的程序哪里出问题呢?无法得到上述右图的表格。谢谢



雷达卡


京公网安备 11010802022788号







