请选择 进入手机版 | 继续访问电脑版
楼主: pingguzh
9183 8

请问用sas如何批量去做卡方检验 [推广有奖]

  • 0关注
  • 4粉丝

菜鸟

副教授

48%

还不是VIP/贵宾

-

威望
0
论坛币
3 个
通用积分
20.0327
学术水平
1 点
热心指数
7 点
信用等级
3 点
经验
19936 点
帖子
873
精华
0
在线时间
433 小时
注册时间
2012-10-29
最后登录
2024-1-28

pingguzh 发表于 2013-11-28 16:50:59 |显示全部楼层 |坛友微信交流群

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
请教各位,我的数据和程序是这样的
  1. data a;
  2. input r c n1 n2 n3@@;
  3. cards;
  4. 1 1 15 82 63 68
  5. 1 2 3 8 15 19
  6. 2 1 71 36 58 11
  7. 2 2 9 14 18 9
  8. ;
  9. proc freq;
  10. weight n1;
  11. tables r*c/chisq;
  12. run;
复制代码

n是样本量,从n1-n999,都要做卡方检验,请问如何批量完成呢?
我之前想到的是用macro,但是也要一个一个的写
比如:
%xx(n1);
%xx(n2);
%xx(n3);
%xx(n4);
等等
能不能用do循环语句配合数组来做呢?谢谢,我对数组真的是不懂啊

二维码

扫码加我 拉你入群

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

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

关键词:卡方检验 Weight tables cards Macro 如何

统计爱好
wwang111 发表于 2013-11-28 17:05:19 |显示全部楼层 |坛友微信交流群
%macro chi;
proc sql noprint;
select name into: varlist separated by " "
from dictionary.columns
where libname='WORK' and memname='A' and name eqt 'N';
quit;

%let i=1;
%do %until(%scan(&varlist,&i)=%str());
proc freq;
weight %scan(&varlist,&i);
tables r*c/chisq;
run;
%let i=%eval(&i+1);
%end;
%mend;

%chi
只有一个罗纳尔多

使用道具

pobel 在职认证  发表于 2013-11-29 08:24:31 |显示全部楼层 |坛友微信交流群

data _null_;
   set sashelp.vcolumn;
   where libname="WORK" and memname="A" and upcase(name)=:"N";
   call execute("proc freq; weight "||strip(name)||"; tables r*c/chisq; run;");
run;
和谐拯救危机

使用道具

pingguzh 发表于 2013-11-29 09:23:23 |显示全部楼层 |坛友微信交流群
wwang111,谢谢,但是你的varlist这里指的是什么变量呢?
统计爱好

使用道具

pingguzh 发表于 2013-11-29 09:24:50 |显示全部楼层 |坛友微信交流群
pobel的程序就不用提了,每次都是经典,非常的感谢
统计爱好

使用道具

jingju11 发表于 2013-11-29 12:28:47 |显示全部楼层 |坛友微信交流群
All the solutions are so good.
Honestly the question is fairly easy to give a solution. But here to this question I have some comments. In my opinion, the key of doing such job is of how fast you can do it. without cosidering that, the simulation will become ugly. Sometimes, you may think of that: don't use macro to repeat algorithm but to repeat text. What i mean is, 1*1000 = 1+1+...+1 (1000). Using macro to loop, sometimes is simliar to adding the 1000's 1 but may hinder you from getting a better way to achieve the goal.
Please read it. JingJu

http://blog.sina.com.cn/s/blog_a3a926360101h2x8.html
已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
webgu + 60 + 60 + 3 + 3 + 3 喜欢京剧的代码,更喜欢京剧的评论!

总评分: 经验 + 60  论坛币 + 60  学术水平 + 3  热心指数 + 3  信用等级 + 3   查看全部评分

使用道具

fisheryou 发表于 2013-11-29 15:05:51 |显示全部楼层 |坛友微信交流群
jingju11 发表于 2013-11-29 12:28
All the solutions are so good.
Honestly the question is fairly easy to give a solution. But here t ...
对于你的回复,我不得不赞一个

使用道具

jpingl1273 发表于 2017-2-21 00:52:44 |显示全部楼层 |坛友微信交流群

使用道具

Cherieling 发表于 2019-12-20 10:32:35 |显示全部楼层 |坛友微信交流群
wwang111 发表于 2013-11-28 17:05
%macro chi;
proc sql noprint;
select name into: varlist separated by " "
请问,如果是对n个txt文件进行批量卡方,而不是对一个数据集中的n的指标进行卡方,宏应该怎么写呢

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-3-29 12:48