p*****o 发帖数: 543 | 1 下面两个程序,第一个是通的,第二个是不通的,想请教一下为什么?
data a;
set b;
if _n_ <= 20;
run;
data a;
set b;
where _n_ <= 20;
run; |
l***a 发帖数: 12410 | 2 you just cannot use it in where statement
【在 p*****o 的大作中提到】 : 下面两个程序,第一个是通的,第二个是不通的,想请教一下为什么? : data a; : set b; : if _n_ <= 20; : run; : data a; : set b; : where _n_ <= 20; : run;
|
S******y 发帖数: 1123 | 3 WHERE conditions are applied before the data enters the input buffer while
IF conditions are applied after the data enters the program data vector.
For more, see
http://www2.sas.com/proceedings/sugi31/238-31.pdf
The _N_ is the temporary variable used to count the iterations of
the DATA step. You cannot reference it in WHERE statement since it has not
been created yet at that time. |
p*****o 发帖数: 543 | 4 Got it.
Thanks a lot!
not
【在 S******y 的大作中提到】 : WHERE conditions are applied before the data enters the input buffer while : IF conditions are applied after the data enters the program data vector. : For more, see : http://www2.sas.com/proceedings/sugi31/238-31.pdf : The _N_ is the temporary variable used to count the iterations of : the DATA step. You cannot reference it in WHERE statement since it has not : been created yet at that time.
|