全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
9564 8
2013-11-28
请教各位,我的数据和程序是这样的
复制代码

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

二维码

扫码加我 拉你入群

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

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

全部回复
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
二维码

扫码加我 拉你入群

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

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

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;
二维码

扫码加我 拉你入群

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

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

2013-11-29 09:23:23
wwang111,谢谢,但是你的varlist这里指的是什么变量呢?
二维码

扫码加我 拉你入群

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

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

2013-11-29 09:24:50
pobel的程序就不用提了,每次都是经典,非常的感谢
二维码

扫码加我 拉你入群

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

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

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
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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