楼主: alflex
2855 8

[原创博文] 求教高手,SAS有没有方法可以让10个观测值一组进行相关系数计算 [推广有奖]

  • 1关注
  • 0粉丝

本科生

90%

还不是VIP/贵宾

-

威望
0
论坛币
74 个
通用积分
3.2000
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
1546 点
帖子
54
精华
0
在线时间
99 小时
注册时间
2008-4-23
最后登录
2025-3-12

楼主
alflex 发表于 2011-12-26 11:11:49 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
面板数据 变量为date code return return_SH,想计算return 和return_SH的相关系数,但要10个变量一组进行overlap计算,有没有好的方法,用proc corr能不能编?
二维码

扫码加我 拉你入群

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

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

关键词:相关系数 有没有 观测值 RETURN turn return 皮尔逊相关系数 偏相关系数 pearson相关系数 相关系数检验 spearman相关系数 复相关系数 相关系数矩阵

回帖推荐

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

## the ways include proc corr and reg, etc; ## requesting only pearson correlation coef. can be solved by data step; 所得的结果应该等同于proc corr nomiss。 所有的代码不保证准确性。无法在sas里调试。只是希望有所参考。 京剧

沙发
bobguy 发表于 2011-12-26 13:08:35
What is your motivation to do it?

藤椅
alflex 发表于 2011-12-26 13:27:06
检验股票异动

板凳
bobguy 发表于 2011-12-27 06:41:39
alflex 发表于 2011-12-26 13:27
检验股票异动
Why not use all sample/data points? By grouping the data, there is nothing you can gain. Unless there is additional information can be gained from grouping.

You can't squeeze blood from a turnip.

报纸
jingju11 发表于 2011-12-27 13:15:54
## the ways include proc corr and reg, etc;
## requesting only pearson correlation coef. can be solved by data step;
  1. data have1;
  2.   set have;  
  3.   if mod(_n_, 10) =1 then grp10 ++1;
  4.   if cmiss(x, y) then call missing(x, y); *delete any missing;
  5. run;
  6. data have2;
  7.   array tx[10] _temporary_; array ty[10] _temporary_;
  8.   call missing(of tx[*]); call missing(of ty[*]);
  9.   do until(last.grp10);
  10.     set have1;
  11.     by grp10;
  12.     num =sum(num, 1);
  13.     tx[num] =x; ty[num] =y;
  14.   end;
  15.   meanX =mean(of tx[*]);  stdX =std(of tx[*]);
  16.   meanY =mean(of ty[*]);  stdY =std(of ty[*]);
  17.   n =n(of tx[*]);
  18.   do until(last.grp10);
  19.     set have1;
  20.     by grp10;
  21.     sum2 =sum(sum2, (x -meanX)*(y -meanY));
  22.   end;
  23.   if n >1 then if (stdX & stdY) then r =sum2/((n-1) *stdX *stdy);
  24.   keep grp10 r;
  25. run;
复制代码
所得的结果应该等同于proc corr nomiss。
所有的代码不保证准确性。无法在sas里调试。只是希望有所参考。
京剧

地板
jintianxiu 发表于 2011-12-27 15:13:23
不知道 大侠是不是使用rolling corr 啊?应该使用proc expand

7
jintianxiu 发表于 2011-12-27 15:13:54
不知道 大侠是不是使用rolling corr 啊?应该使用proc expand

8
jingju11 发表于 2011-12-28 03:07:57
Does proc expand report correlation coef.?
jingju

9
alflex 发表于 2011-12-28 15:26:36
今天试用了一下五楼余数的方法,还是很好用的,谢谢啦,至于rolling那个,看都看不太懂,我的SAS水平太低了,还得多向各位学习啊~

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-3 19:19