武大SAS要点步骤.docx
- 文档编号:5089184
- 上传时间:2022-12-13
- 格式:DOCX
- 页数:43
- 大小:255.09KB
武大SAS要点步骤.docx
《武大SAS要点步骤.docx》由会员分享,可在线阅读,更多相关《武大SAS要点步骤.docx(43页珍藏版)》请在冰豆网上搜索。
武大SAS要点步骤
例2-1例数、均数、标准差、标准误、95%可信区间
1、sas过程
dataex2_1;
inputx@@;
cards;
3.964.234.423.595.124.024.323.724.764.164.614.26
3.774.204.363.074.893.974.283.644.664.044.554.25
4.633.914.413.525.034.014.304.194.754.144.574.26
4.563.793.894.214.953.984.293.674.694.124.564.26
4.664.283.834.205.244.024.333.764.814.173.963.27
4.614.263.964.233.764.014.293.673.394.124.273.61
4.984.243.834.203.714.034.344.693.624.184.264.36
5.284.214.424.363.664.024.314.833.593.973.964.49
5.114.204.364.543.723.974.284.763.214.044.564.25
4.924.234.473.605.234.024.324.684.763.694.614.26
3.894.214.363.425.014.014.293.684.714.134.574.26
4.035.464.163.644.163.76
;
procmeansdata=ex2_1
nmeanstdstderrclm;
varx;
run;
2、输出结果
例2-1
(2)中位数、四分位数间距
1、sas过程
dataex2_1;
inputx@@;
cards;
3.964.234.423.595.124.024.323.724.764.164.614.26
3.774.204.363.074.893.974.283.644.664.044.554.25
4.633.914.413.525.034.014.304.194.754.144.574.26
4.563.793.894.214.953.984.293.674.694.124.564.26
4.664.283.834.205.244.024.333.764.814.173.963.27
4.614.263.964.233.764.014.293.673.394.124.273.61
4.984.243.834.203.714.034.344.693.624.184.264.36
5.284.214.424.363.664.024.314.833.593.973.964.49
5.114.204.364.543.723.974.284.763.214.044.564.25
4.924.234.473.605.234.024.324.684.763.694.614.26
3.894.214.363.425.014.014.293.684.714.134.574.26
4.035.464.163.644.163.76
;
procmeansdata=ex2_1
nmedianQrange;
varx;
run;
2、输出结果
例2-1(3)百分位数
1、sas过程
dataex2_1;
inputx@@;
cards;
3.964.234.423.595.124.024.323.724.764.164.614.26
3.774.204.363.074.893.974.283.644.664.044.554.25
4.633.914.413.525.034.014.304.194.754.144.574.26
4.563.793.894.214.953.984.293.674.694.124.564.26
4.664.283.834.205.244.024.333.764.814.173.963.27
4.614.263.964.233.764.014.293.673.394.124.273.61
4.984.243.834.203.714.034.344.693.624.184.264.36
5.284.214.424.363.664.024.314.833.593.973.964.49
5.114.204.364.543.723.974.284.763.214.044.564.25
4.924.234.473.605.234.024.324.684.763.694.614.26
3.894.214.363.425.014.014.293.684.714.134.574.26
4.035.464.163.644.163.76
;
procunivariatedata=ex2_1;
varx;
outputout=pct
pctlpre=p
pctlpts=2.597.5;
run;
procprintdata=pct;
run;
2、结果输出
3、结果解释
从结果中可以看出2.5%和97.5%分别为3.39和5.23
例2-5求几何均数
dataex2_5;
inputxf@@;
y=log10(x);
cards;
104
203
4010
8010
16011
32015
64014
12802
;
procmeansnoprint;
vary;
freqf;
outputout=b
mean=logmean;
run;
datac;
setb;
g=10**logmean;
procprintdata=c;
varg;
run;
例3-2求95%可信区间
dataex3_2;
n=10;
mean=166.95;
std=3.64;
t=tinv(0.975,n-1);
pts=t*std/sqrt(n);
lclm=mean-pts;
uclm=mean+pts;
procprint;
varlclmuclm;
run;
例3-4求两总体相差多大(区间估计)
dataex3_4;
n1=29;
n2=32;
m1=20.10;
m2=16.89;
s1=7.02;
s2=8.46;
ss1=s1**2*(n1-1);
ss2=s2**2*(n2-1);
sc2=(ss1+ss2)/(n1+n2-2);
se=sqrt(sc2*(1/n1+1/n2));
t=tinv(0.975,n1+n2-2);
lclm=(m1-m2)-t*se;
uclm=(m1-m2)+t*se;
procprint;
vartselclmuclm;
run;
例3-5单样本t检验
1、sas过程
dataex3_5;
n=36;
s_m=130.83;
std=25.74;
p_m=140;
df=n-1;
t=abs(s_m-p_m)/(std/sqrt(n));
p=(1-probt(t,df))*2;
procprint;
vartp;
run;
2、结果输出
3、结果解释
可以看到,检验统计量t=-2.13753,其对应的P值为0.039618,小于显著性水平的临界值0.05,故拒绝H0,接受H1,即认为样本均数与总体均数在统计学上具有显著性差异。
例3-6配对样本t检验
1、sas过程
dataex3_6;
inputx1x2@@;
d=x1-x2;
cards;
0.8400.580
0.5910.509
0.6740.500
0.6320.316
0.6870.337
0.9780.517
0.7500.454
0.7300.512
1.2000.997
0.8700.506
;
procmeanstprt;
vard;
run;
procunivariatedata=ex3_6;
vard;
run;
2、结果输出
3、结果解释
从结果中可以看出检验统计量t值为7.93.对应的p<0.0001,按α=0.05水准,拒绝H0,接受H1,差异有统计学意义,即认为配对资料两样本均数在统计学上具有显著性差异。
例3-7两样本t检验
1、sas过程
dataex3_7;
inputx@@;
if_n_<21thenc=1;
elsec=2;
cards;
-0.70-5.602.002.800.703.504.005.807.10-0.50
2.50-1.601.703.000.404.504.602.506.00-1.40
3.706.505.005.200.800.200.603.406.60-1.10
6.003.802.001.602.002.201.203.101.70-2.00
;
procttest;
varx;
classc;
run;
2、结果输出
3、结果解释
首先进行方差齐性检验,结果显示统计量F值为1.60,对应额的P值为0.3153,大于显著性水平的临界值0.05,认为两样本具有方差齐性;然后对两样本均数进行差异性分析,结果显示统计量T值为-0.64,对应的P值为0.5248,大于0.05,接受H0,即认为两样本均数不具有显著性差异。
例4-2完全随机设计资料的方差分析
dataex4_2;
inputxc@@;
cards;
3.5312.4222.8630.894
4.5913.3622.2831.064
4.3414.3222.3931.084
2.6612.3422.2831.274
3.5912.6822.4831.634
3.1312.9522.2831.894
3.3012.3623.4831.314
4.0412.5622.4232.514
3.5312.5222.4131.884
3.5612.2722.6631.414
3.8512.9823.2933.194
4.0713.7222.7031.924
1.3712.6522.6630.944
3.9312.2223.6832.114
2.3312.9022.6532.814
2.9811.9822.6631.984
4.0012.6322.3231.744
3.5512.8622.6132.164
2.6412.9323.6433.374
2.5612.1722.5832.974
3.5012.7223.6531.694
3.2511.5623.2131.194
2.9613.1122.2332.174
4.3011.8122.3232.284
3.5211.7722.6831.724
3.9312.8023.0432.474
4.1913.5722.8131.024
2.9612.9723.0232.524
4.1614.0221.9732.104
2.5912.3121.6833.714
;
procanova;
classc;
modelx=c;
meansc/dunnett;
meansc/hovtest;
run;
Pr>F,方差齐
例4-4随机区组设计资料的方差分析
dataex4_4;
inputxab@@;
cards;
0.8211
0.6521
0.5131
0.7312
0.5422
0.2332
0.4313
0.3423
0.2833
0.4114
0.2124
0.3134
0.6815
0.4325
0.2435
;
procanova;
classab;
modelx=ab;
meansa/snk;
run;
例7-1四格表卡方检验
dataex7_1;
inputrcf@@;
cards;
1199
125
2175
2221
;
procfreq;
weightf;
tablesr*c
/chisq
expected;
run;
例7-2校正卡方检验
dataex7_2;
inputrcf@@;
cards;
1146
126
2118
228
;
procfreq;
weightf;
tablesr*c
/chisq
expected;
run;
例7-6多个样本率的比较
dataex7_6;
inputrcf@@;
cards;
11199
127
21164
2218
31118
3226
;
procfreq;
weightf;
tablesr*c
/chisq;
run;
例7-7样本构成比的比较
dataex7_7;
inputrcf@@;
cards;
1142
1248
1321
2130
2272
2336
;
procfreq;
weightf;
tablesr*c
/chisq;
run;
例7-8双向无序分类资料的关联性检验
dataex7_8;
inputrcf@@;
cards;
11431
12490
13902
21388
22410
23800
31495
32587
33950
41137
42179
4332
;
procfreq;
weightf;
tablesr*c
/chisq;
run;
例8-1配对样本比较的Wilcoxon符号秩检验
dataex8_1;
inputx1x2@@;
d=x1-x2;
cards;
6076
142152
195243
8082
242240
220220
190205
2538
198243
3844
236190
95100
;
procunivariate;
vard;
run;
例8-3两个独立样本比较的Wilcoxon秩和检验
dataex8_3;
inputxc@@;
cards;
2.781
3.231
4.201
4.871
5.121
6.211
7.181
8.051
8.561
9.601
3.232
3.502
4.042
4.152
4.282
4.342
4.472
4.642
4.752
4.822
4.952
5.102
;
procnpar1waywilcoxon;
varx;
classc;
run;
一、多元回归
1、普通多元回归
dataa;
inputidx1-x4y;
cards;
1173106714.7137
21391326.417.8162
31981126.916.7134
41181387.115.7188
5139948.613.6138
617516012.120.3215
713115411.221.5171
81581419.729.6148
91581377.418.2197
101321517.517.2113
11162110615.9145
1214411310.142.881
131621377.220.7185
141691298.516.7157
151291386.310.1197
1616614811.533.4156
17185118617.5156
181551216.120.4154
191751114.127.2144
201361109.42690
211531338.516.9215
221101499.524.7184
23160865.310.8118
24112123816.6127
251471108.518.4137
262041226.121126
271311026.613.4130
2817011278.424.7135
291731238.719188
3013213113.829.2122
;
procreg;
modely=x1-x4/stb;
run;
结果解释:
根据方差分析结果:
F=4.26,P=0.0092<0.05,回归方程有统计学意义
根据参数估计结果:
仅X3有意义,t=-2.42,P<0.05
回归方程是:
=178.47344+0.09028X1-0.00104X2-1.3939X3-1.40112X4
2、多元回归(逐步回归法)
dataa;
inputidx1-x5y;
cards;
1173106714.713762
21391326.417.816243
31981126.916.713481
41181387.115.718839
5139948.613.613851
617516012.120.321565
713115411.221.517140
81581419.729.614842
91581377.418.219756
101321517.517.211337
11162110615.914570
1214411310.142.88141
131621377.220.718556
141691298.516.715758
151291386.310.119747
1616614811.533.415649
17185118617.515669
181551216.120.415457
191751114.127.214474
201361109.4269039
211531338.516.921565
221101499.524.718440
23160865.310.811857
24112123816.612734
251471108.518.413754
262041226.12112672
271311026.613.413051
2817011278.424.713562
291731238.71918885
3013213113.829.212238
;
procreg;
modely=x1-x5/stbselection=stepwisesle=0.10sls=0.15;
run;
结果解释:
根据逐步回归的条件:
引入标准=0.10,剔除标准=0.15,回归方程纳入X1和X4,P均小于0.05
由方差分析结果显示:
F=46.48,P<0.0001,回归方程有统计学意义。
根据参数估计结果显示:
=-11.78059+0.49842X1-0.49666X4
3.控制变量后的相关系数
dataa;
inputidx1-x5y;
cards;
1173106714.713762
21391326.417.816243
31981126.916.713481
41181387.115.718839
5139948.613.613851
617516012.120.321565
713115411.221.517140
81581419.729.614842
91581377.418.219756
101321517.517.211337
11162110615.914570
1214411310.142.88141
131621377.220.718556
141691298.516.715758
151291386.310.119747
1616614811.533.415649
17185118617.515669
181551216.120.415457
191751114.127.214474
201361109.4269039
211531338.516.921565
221101499.524.718440
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- SAS 要点 步骤