我有一些数据是这样的:
Date Close
12/31/2014 222.41
12/30/2014 222.23
12/29/2014 225.71
12/26/2014 227.82
12/24/2014 222.26
12/23/2014 220.97
12/22/2014 222.6
12/19/2014 219.29
12/18/2014 218.26日期范围涵盖2013至14年整整两年。
我想做一个配对的T测试关闭,但我正在为我的语法挣扎。想必我需要把日期转换成年份?或者是我?2013年的每一个日期都与2014年的另一个日期相匹配。
我可以在csv中更改数据并将其设置为:
Date | 2013_Close | 2014_Close
Jan 1| 101 | 204
Jan 2| 105 | 210但是,如果我想避免这种情况,是否有办法对数据进行配对T-检验?
以下是我尝试过的,但我收到了错误:
proc ttest data=tsla sides=2 alpha=0.05 h0=0;
class Date;
format Date year.;
var Close;
paired 2014*2013;
run;
ERROR 22-322: Syntax error, expecting one of the following: a name, (.
ERROR 76-322: Syntax error, statement will be ignored.但即便如此,SAS怎么知道2013年和14岁呢?在英语中,我需要告诉SAS在接近配对日期的地方进行配对的T测试。
这有意义吗?我该怎么做?
发布于 2015-02-05 15:30:32
为了进行配对T检验,我认为您需要得到数据如下所示:
DayofYear Close2013 Close2014
365 222.41 222.26
364 222.23 220.97
363 225.71 222.6
362 227.82 219.29
361 222.26 222.41
360 220.97 222.23
359 222.6 225.71
358 219.29 227.82
357 218.26 222.26这样做的一种方法是为DayofYear创建一个变量,然后使用proc sql将表的2013年部分与表中的2014年部分自连接,如下所示:
proc sql;
select
coalesce(t1.dayofyear,t2.dayofyear) as dayofyear,
t1.close as close2013,
t2.close as close2014
from
(select * from tsla where year(date)=2013) t1
full outer join (select * from tsla where year(date)=2014) t2
on t1.dayofyear = t2.dayofyear
;
quit;
;
quit;要运行测试,我认为您不应该需要class、var或format语句。只有paired close2013*close2014;语句。
https://stackoverflow.com/questions/28347076
复制相似问题