楼主: lilinzhong
1871 5

[原创博文] SAS-data [推广有奖]

  • 0关注
  • 0粉丝

大专生

18%

还不是VIP/贵宾

-

威望
0
论坛币
13 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
1073 点
帖子
39
精华
0
在线时间
30 小时
注册时间
2006-12-5
最后登录
2016-2-29

楼主
lilinzhong 发表于 2010-2-3 16:18:13 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
data x;
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;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Data Input cards card sign

回帖推荐

jingju11 发表于3楼  查看完整内容

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

本帖被以下文库推荐

沙发
醉_清风 发表于 2010-2-3 16:46:22
不明白你想干嘛...
从来不需要想起 永远也不会忘记

藤椅
jingju11 发表于 2010-2-3 21:54:50
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
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

板凳
bobguy 发表于 2010-2-4 07:08:11
lilinzhong 发表于 2010-2-3 16:18
data x;
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;
Boolean value in SAS has one of only two values, {1, 0}    1=true , 0= false

In the case


z=y>0+x>0;

is the same as z=y>(0+x)>0; accoring to the operation order.
x  y
1 2        2>1>0   {true}    z=1;
0 1        1>0>0   {false}  z=0
-1 3       3>-1>0 {false}  z=0

That is what you see.

报纸
jingju11 发表于 2010-2-4 07:40:01
3# jingju11

the expression here z = y>0+x>0 is equivalent to z = (y>0+x)>0


Clearly I was wrong. Sorry about that and thanks for the correction. So,

z = y>0+x>0 is equivalent to z = (y>(0+x)>0)

JingJu

地板
lilinzhong 发表于 2010-2-4 09:46:05
谢谢,解决了。果然如此,忽略了这个细节。

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-27 20:44