# SAS比较不同年龄段组间差异，卡方检验

## SAS比较不同年龄段组间差异，卡方检验

data a;
input count r\$ c\$;
cards;
184 A 0
115 B 0
51 C 0
24 D 0
1809 A 1
1048 B 1
280 C 1
49 D 1
;
run;
proc print data=a; run; /*看一眼数据*/

proc freq data=a;
tables r*c/chisq;   /*四组年龄段组间比较一下*/
weight count;
run;

proc freq data=a;
where r in('A','B');
tables r*c/chisq;
weight count;
run;

proc freq data=a;
where r in('A','C');
tables r*c/chisq;
weight count;
run;

proc freq data=a;
where r in('A','D');
tables r*c/chisq;
weight count;
run;
proc freq data=a;
where r in('B','C');
tables r*c/chisq;
weight count;
run;
proc freq data=a;
where r in('B','D');
tables r*c/chisq;
weight count;
run;
proc freq data=a;
where r in('C','D');
tables r*c/chisq;
weight count;
run;

%macro group_chisq(a,g1,g2);
proc freq data=&a;
where r in("&g1","&g2");
tables r*c/chisq;
weight count;
run;
%mend;
%group_chisq(a,A,B)
%group_chisq(a,A,C)
%group_chisq(a,A,D)
%group_chisq(a,B,C)
%group_chisq(a,B,D)
%group_chisq(a,C,D)

原文作者：傲寒和祝星你们可还好
原文地址: https://blog.csdn.net/weixin_41934690/article/details/104327446
本文转自网络文章，转载此文章仅为分享知识，如有侵权，请联系博主进行删除。