其他分享
首页 > 其他分享> > SAS | TTEST

SAS | TTEST

作者:互联网

利用汇总统计量进行成组 t 检验

建立数据集

data dt1;
    input type$ gain @@;
    datalines;
    a 45 a 62 a 96 a 128
    a 120 a 99 a 28 a 50
    a 109 a 115 a 39 a 96
    a 87 a 100 a 76 a 80
    b 94 b 12 b 26 b 89
    b 88 b 96 b 85 b 130
    b 75 b 54 b 112 b 69
    b 104 b 95 b 53 b 21
    ;
run;

使用means过程生成汇总统计量

proc means data=dt1;
    var gain;
    by type;
    output out=dt1out;
run;

使用ttest语句进行两样本成组t检验

proc ttest data=dt1out;
    var gain;
    class type;
run;

使用ttest和freq语句进行单样本t检验

建立数据集,其中,score变量是分数,count变量是各分数出现的频数。

data dt2;
    input score count @@;
    datalines;
    40 2 47 2 52 2 26 1 19 2
    25 2 35 4 39 1 26 1 48 1
    14 2 22 1 42 1 34 2 33 2
    18 1 15 1 29 1 41 2 44 1
    51 1 43 1 27 2 46 2 28 1
    49 1 31 1 28 1 54 1 45 1
    ;
run;

使用ttest和freq语句进行单样本t检验,同时设定h0=30。

proc ttest data=dt2 h0=30;
    var score;
    freq count;
run;

使用ttest和paired语句进行两样本配对t检验

建立数据集,其中before变量是处理前数据,after变量是处理后数据。

data dt3;
    input before after @@;
    datalines;
    120 128 124 131 130 131 118 127
    140 132 128 125 140 141 135 137
    126 118 130 132 126 129 127 135
    ;
run;

使用ttest和paired语句进行配对样本t检验。其中before*after会被处理为before-after。如果要检验处理后-处理前与h0的关系,应当指定after*before。

proc ttest data=dt3;
    paired before*after;
run;

使用ttest语句和paired语句,同时指定after*before和h0=2进行配对样本t检验。

proc ttest data=dt3 h0=2;
    paired after*before;
run;

交叉设计t检验

未读

对数正态数据等效t检验

未读

bootstrap语句两样本成组t检验

未读

标签:run,after,检验,ttest,SAS,data,TTEST,before
来源: https://www.cnblogs.com/cp45899/p/16609189.html