input x y;
z=y>0+x>0; --------改成z=y>0; 可以
cards;
1 2
0 1
-1 3
;
run;
得不到正确的结果,why??
data x;
input x y;
z=sum(sign(x) ,sign(y) ); 用符号函数可以解决
cards;
1 2
0 1
. 3
;
run;

|
楼主: lilinzhong
|
1871
5
[原创博文] SAS-data |
|
大专生 18%
-
|
回帖推荐1# lilinzhong
In view of the Order of Evaluation in Compound Expressions in SAS, the expression here z = y>0+x>0 is equivalent to z = (y>0+x)>0, but you were expecting z = (y>0)+(x>0). I think this is where the discrepancy comes from. I would suggest that you properly using brackets to make the expression more explicit.
JingJu
本帖被以下文库推荐
| ||
|
|
| ||
| ||
加好友,备注cda京ICP备16021002号-2 京B2-20170662号
京公网安备 11010802022788号
论坛法律顾问:王进律师
知识产权保护声明
免责及隐私声明


