全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
5845 10
2010-07-31
我是试用从WRDS 上下载的SAS code做的动量策略,例子里的数据是从CRSP 上下载的美国股市1965-1989的数据(sas格式),用这个的时候,这组code运行的很好,结果也和例子一样,可是当我换了一组变量名称一样的excel格式的数据时,系统出现了好多错误,这是怎么回事啊?我在换数据的时候,名称都对应和例子里的一样!而且我sas9.1和8.2两个版本都试了,都是一样的结果!请教高手这是为什么?下面是错误的地方:
178  proc sql;
179      create table umd
180      as select distinct a.permno, a.date, exp(sum(log(1+b.ret))) - 1 as cum_return
181      from msex2 (keep=permno date) as a, msex2 as b
182      where a.permno=b.permno and 0<=intck('month', b.date, a.date)<&J
183    group by a.permno, a.date
184    having count(b.ret)=&J;
ERROR: Expression using addition (+) requires numeric types.
ERROR: Function INTCK requires a numeric expression as argument 2.
ERROR: Function INTCK requires a numeric expression as argument 3.
ERROR: Expression using less than or equal (<=) has components that are of different data types.
ERROR: Function INTCK requires a numeric expression as argument 2.
ERROR: Function INTCK requires a numeric expression as argument 3.
ERROR: Expression using less than  (<) has components that are of different data types.
185  quit;
二维码

扫码加我 拉你入群

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

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

全部回复
2010-7-31 04:02:16
can you run proc contents for data msex2
to check types of related variables first?
二维码

扫码加我 拉你入群

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

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

2010-7-31 04:19:24
2# mydo Thank u very much. After run the contents, I found that all the variable types are characteristic, not numeric. But how can I change the data type? Acturally, there are all date and return, that is numerical, right?
本文来自: 人大经济论坛 SAS专版 版,详细出处参考:http://www.pinggu.org/bbs/viewthread.php?tid=872423&page=1&from^^uid=936067
二维码

扫码加我 拉你入群

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

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

2010-7-31 04:39:52
3# guqing1222
你用的是什么破excel?居然让sas吧日期当成text来读。如果现象奇怪,就说明可能有问题。所以往往不是转换类型就能解决的。
二维码

扫码加我 拉你入群

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

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

2010-7-31 05:28:33
4# jingju11 哦,这样子,,,我也觉得有问题,只是看不出来问题在哪里。 我换成了numeric以后,错误跟着变成了:178  proc sql;
179      create table umd
180      as select distinct a.PERMNO, a.DATE, exp(sum(log(1+b.RET))) - 1 as cum_return
181      from msex2 (keep=permno date) as a, msex2 as b
182      where a.permno=b.permno and 0<=intck('month', b.date, a.date)<&J
183    group by a.permno, a.date
184    having count(b.ret)=&J;
NOTE: Invalid argument 1 to function INTCK. Missing values may be generated.
NOTE: Invalid arguments to the LOG function have caused the function to return a missing value.
NOTE: Table WORK.UMD created, with 0 rows and 3 columns.
185  quit;
NOTE: PROCEDURE SQL used:
      real time           0.13 seconds
      cpu time            0.13 seconds
不知道这个公式哪里错了,因为刚才用sample数据的时候还好好的。。
二维码

扫码加我 拉你入群

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

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

2010-7-31 06:21:54
试试用STAT/TRANSFER先把数据从excel格式转换成SAS格式
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群