l*********g 发帖数: 177 | 1 先上2个代码
代码1:
proc sql;
create table temp1
as select distinct a.permno, b.*
from DivEvents a, caldates b
where b.evt_date-a.date =0
;
quit;
代码2:
proc sql;
create table temp1
as select distinct a.permno, b.*
from DivEvents a, caldates b
where b.evt_date=a.date
;
quit;
按我的理解,这2个代码照理应该是得到同样的结果。但是我发现结果居然极为不同,
其中代码1只生成了6000个observation,而代码2生成了210000个observation。代码2
是我要的结果,但是我不明白为什么代码1会有不同结果,我开始担心我是否其他code
里有出现相关的bug了。请大家指点一下怎么回事把?为什么不同结果呢?非常谢谢! | xi 发帖数: 1678 | 2 missing value?
【在 l*********g 的大作中提到】 : 先上2个代码 : 代码1: : proc sql; : create table temp1 : as select distinct a.permno, b.* : from DivEvents a, caldates b : where b.evt_date-a.date =0 : ; : quit; : 代码2:
| l*********g 发帖数: 177 | 3 没有哦,2个dataset的column date 或 evt_date 都是没有missing values的哦。
【在 xi 的大作中提到】 : missing value?
| d******9 发帖数: 404 | 4 Since date is numeric value, SAS stores numeric values and do numeric
calculations in floating point way, therefore X=Y, and X-Y=0 may give
different results.
This is probably the reason.
To test it: try to use the below modified condition
where round(b.evt_date-a.date, 1.) =0 | l*********g 发帖数: 177 | 5 确实是这个问题哦!非常感谢 └(^o^)┘
【在 d******9 的大作中提到】 : Since date is numeric value, SAS stores numeric values and do numeric : calculations in floating point way, therefore X=Y, and X-Y=0 may give : different results. : This is probably the reason. : To test it: try to use the below modified condition : where round(b.evt_date-a.date, 1.) =0
|
|