sas统计分析代码.docx

上传人:b****3 文档编号:27134274 上传时间:2023-06-27 格式:DOCX 页数:28 大小:21.84KB
下载 相关 举报
sas统计分析代码.docx_第1页
第1页 / 共28页
sas统计分析代码.docx_第2页
第2页 / 共28页
sas统计分析代码.docx_第3页
第3页 / 共28页
sas统计分析代码.docx_第4页
第4页 / 共28页
sas统计分析代码.docx_第5页
第5页 / 共28页
点击查看更多>>
下载资源
资源描述

sas统计分析代码.docx

《sas统计分析代码.docx》由会员分享,可在线阅读,更多相关《sas统计分析代码.docx(28页珍藏版)》请在冰豆网上搜索。

sas统计分析代码.docx

sas统计分析代码

 

/*统计描述*/

/*制作频数表*/

dataa1;

inputx@@;

low=;

dis=;

z=x-mod(x-low,dis);

cards;

12

34

;

procfreq;

tablesz;

run;

/*用meaNS过程计算例数、均数、标准差、标准误和95%可信区间*/

procmeansnmeanstdstderrclm;

varx;

run;

/*用means过程对频数表计算例数、均数、标准差、最大值最小值*/

procmeans;

freqf;

varx;

run;

procunivariate;

freqf;

varx;

run;

/*正态性检验*/

procunivariatenormalplot;

varx;

run;

/*t检验*/

dataaa3;

inputx;

y=x-比较的数;

/*配对资料d=x1-x2*/

cards;

;

procunivariatenormal;

vary;

run;

/*用MEANS作配对资料两个样本均数比较的t检验*/

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;

/*用UNIVARIATE过程作配对资料两样本均数比较的t检验*/

procunivariatedata=ex3_6;

vard;

run;

procttestdata=ex3_6;

vard;

run;

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;

/*方差分析*/

DATARANDOM;

INPUTXGROUP@@;

CARDS;

3.531

4.591

4.341

2.661

3.591

3.131

2.641

2.561

3.501

3.251

3.301

4.041

3.531

3.561

3.851

4.071

3.521

3.931

4.191

2.961

1.371

3.931

2.331

2.981

4.001

3.551

2.961

4.301

4.161

2.591

2.422

3.362

4.322

2.342

2.682

2.952

1.562

3.112

1.812

1.772

1.982

2.632

2.862

2.932

2.172

2.722

2.652

2.222

2.902

2.972

2.362

2.562

2.522

2.272

2.982

3.722

2.802

3.572

4.022

2.312

2.863

2.283

2.393

2.283

2.483

2.283

3.213

2.233

2.323

2.683

2.663

2.323

2.613

3.643

2.583

3.653

2.663

3.683

2.653

3.023

3.483

2.423

2.413

2.663

3.293

2.703

3.043

2.813

1.973

1.683

0.894

1.064

1.084

1.274

1.634

1.894

1.194

2.174

2.284

1.724

1.984

1.744

2.164

3.374

2.974

1.694

0.944

2.114

2.814

2.524

1.314

2.514

1.884

1.414

3.194

1.924

2.474

1.024

2.104

3.714

;

RUN;

/*正态性检验*/

PROCUNIVARIATENORMAL;

CLASSGROUP;

VARX;

RUN;

PROCANOVA;

CLASSGROUP;

MODELX=GROUP;

MEANSGROUP/HOVTESTSNKLSDDUNNETT;

RUN;

/*hovtest方差齐性检验*/

/*方差分析*/

PROCGLM;

CLASSGROUP;

MODELX=GROUP;

MEANSGROUP/HOVTESTSNKLSDDUNNETT;

RUN;

DATAA;

INPUTXTREATBLOCK@@;

CARDS;

0.8211

0.7312

0.4313

0.4114

0.6815

0.6521

0.5422

0.3423

0.2124

0.4325

0.5131

0.2332

0.2833

0.3134

0.2435

;

RUN;

PROCPRINT;RUN;

PROCANOVA;

CLASSTREATBLOCK;

MODELX=TREATBLOCK;

MEANSTREAT/SNKALPHA=0.05;

MEANSTREAT;

RUN;

 

DATABLOCK;

INPUTBLOCKTREATX@@;

CARDS;

110.82120.65130.51

210.73220.54230.23

310.43320.34330.28

410.41420.21430.31

510.68520.43530.24

;

PROCANOVA;

CLASSBLOCKTREAT;

MODELX=BLOCKTREAT;

MEANSTREAT/HOVTESTSNKLSDDUNNETT;

RUN;

;

PROCGLM;

CLASSBLOCKTREAT;

MODELX=BLOCKTREAT;

MEANSTREAT/HOVTESTSNKLSDDUNNETT;

RUN;

/*roc曲线分析*/

dataex21;

inputgroupnum;

doi=1tonum;

inputvalue@@;

output;end;

cards;

125

6.513.512.86.213.914.79.59.06.916.8

13.310.812.214.913.712.85.311.812.4

7.613.311.911.212.312.7

020

8.56.44.61.79.75.34.95.73.86.5

6.35.43.34.78.66.35.94.84.55.2

;

run;

proclogisticdescending;

modelgroup=value/scale=noneoutroc=rocl;

run;

procprint;

run;

procgplot;

plot_SENSIT_*_1MSPEC_;

run;

DATACHISQGROUP;

INPUTCOLROWX@@;

CARDS;

1146126

2118228

;

PROCFREQ;

WEIGHTX;

TABLECOL*ROW/CHISQ;

RUN;

DATACHISQPAIRED;/*请注意配对结果中没有进行校正,所以对于需要校正的情况,需要手动计算。

但是别的一些软件可以实现校正。

*/

INPUTCOLROWX@@;

CARDS;

11111212

2122233

;

PROCFREQ;

WEIGHTX;

TABLECOL*ROW/AGREE;

RUN;

/*行*列表资料注意资料录入格式*/

/*非参数检验过程步格式*/

DATAPAIRED;

INPUTX1X2@@;

D=X1-X2;

CARDS;

6080

142152

195243

8082

242240

220220

190205

2538

212243

3844

236200

95100

;

PROCUNIVARIATE;

VARD;

RUN;

PROCNPAR1WAY;

BYvariables;

CLASSvariable;

EXACTstatistic-options;

FREQvariable;

OUTPUT;

VARvariables;

RUN;

DATAGROUPED;

INPUTXGROUP@@;

CARDS;

2.7813.232

3.2313.502

4.2014.042

4.8714.152

5.1214.282

6.2114.342

7.1814.472

8.0514.642

8.5614.752

9.6014.822

4.952

5.102

;

PROCNPAR1WAY;

CLASSGROUP;

VARX;

RUN;

DATAmysas.A1127;

INPUTIDAGEINDEX;

CARDS;

1133.54

2113.01

393.09

462.48

582.56

6103.36

7123.18

872.65

;

PROCCORR;

VARAGEINDEX;

RUN;

PROCREG;

MODELINDEX=AGESELECTION=STEPWISE

SLE=0.10SLS=0.10;

PLOTINDEX*AGE;

RUN;

proclogisticdescending;

modely=xSELECTION=STEPWISE

SLE=0.10SLS=0.10;

run;

/*条件逻辑回归*/

dataa;

inputiyx1-x6;

yy=2-y;

procphreg;

modelyy*y(0)=x/risklimitsselection=stepwise

sle=0.1sls=0.1ties=discrete;

STRATA=i;

run;

/*生存分析km法*/

PROCLIFETESTMETHOD=kmPLOTS=(S);

TIMEtime*censor

(1);

STRATAgroup;

RUN;

dataa;

inputtimegroupcensor@@;

cards;

111011510600025400

3211124101020028100

4210174111650029501

4210186101890145800

71102781020000

;

PROCLIFETESTMETHOD=kmPLOTS=(S);

TIMEtime*censor

(1);

STRATAgroup;

RUN;

/*生存分析寿命表法km*/

DATAsamp12_3;

INPUTtcensorf@@;

CARDS;

0176009

1168108

2142203

3118301

419400

5105024

;

PROCPRINT;

PROCLIFETESTMETHOD=ltPLOTS=(s)WIDTH=1;

TIMEt*censor(0);

FREQf;

RUN;

/*cox回归*/

dataa;

inputnumsexagestagebloodxraychmthrpcensorday;

cards;

114522011578

2036220111549

315722101938

4045201004717

5042201114111

6039210111245

7138211114435

8145221013750

9130201013958

10045210112581

11045310113572

12157211012938

13057220111932

14149221113205

15133210113451

16051221012363

;

PROCPHREG;

Modelday*censor(0)=sexagestagebloodxraychmthrp/

risklimits;

RUN;

/*判别分析*/

datad2;

doi=1to16;

dogrp=1to2;

inputidx1x2@@;output;end;end;

cards;

19.865.18110.662.07

213.333.73212.534.45

……

1513.335.961511.203.42

16..169.333.63

run;

procdiscrimdata=d2

outstat=outanovamanovapool=testlisterrposterr;

classgrp;

varx1x2;

priorsprop;

run;

/*判别分析*/

dataex18_4;

inputx1-x4g;

cards;

6.0-11.519901

-11.0-18.525-363

90.2-17.01732

-4.0-15.013541

0.0-14.020352

0.5-11.519373

-10.0-19.021-423

0.0-23.05-351

20.0-22.08-203

-100.0-21.47-151

-100.0-21.515-402

13.0-17.21822

-5.0-18.515181

10.0-18.014501

-8.0-14.016561

0.6-13.026213

-40.0-20.022-503

;

procdiscrim;

classg;

varx1-x4;

priorsprop;run;

/*样品聚类*/

dataex19_3;

inputx1-x10;

cards;

4625521381.680.358.11441

35122035102.761.436.84331

52252027842.190.544.11331

3272024511.930.4711.45961

3822032472.560.8011.68551

51313037102.920.3711.60221

4091031942.510.4011.40551

34172046583.670.4611.35331

5029050193.950.4713.451081

42202074825.890.1213.11002

57301538002.990.1910.76221

36152024781.950.2510.00001

3712038273.010.8210.50441

5232029842.350.1611.15331

52321037492.950.7211.4511101

42273049413.890.7313.80761

44272039483.110.3313.6516141

4021533602.640.3711.40001

3821529362.310.6911.40111

44272068515.390.9912.28762

4327039263.090.4711.95001

2610343813.450.5211.80751

37182071425.620.8511.81552

2892026122.060.3711.65111

2593026382.080.7812.25111

34142043223.400.4115.00551

50322028622.250.698.80221

;

proccluster

method=average;

varx1-x10;

run;

proctree;

run;

/*指标聚类*/

procvarclusdata=ex19_3;

varx1-x10;

run;

/*主成分分析*/

dataex20_1;

inputx1-x4;

cards;

402.0520

101.5530

1203.01350

2504.5180

1203.5950

101.51250

401.01940

2704.01360

2803.51160

1703.0960

1803.51440

1302.03050

2201.51720

1601.53560

2202.51430

1402.02020

2202.01410

401.0100

201.01260

1202.0200

;

procprincomp;

varx1-x4;

run;

/*因子分析*/

dataex20_2;

inputx1-x9;

cards;

4.3438999.061.2325.4693.153.5697.5161.66

3.4527188.280.8523.5594.312.4497.9473.33

4.38385103.971.2126.5492.534.0298.4876.79

4.1837799.481.1926.8993.862.9299.4163.16

4.32378102.011.1927.6393.181.9999.7180.00

4.1334997.551.1027.3490.634.3899.0363.16

4.5736191.661.1424.8990.602.7399.6973.53

4.3120962.180.5231.7491.673.6599.4861.11

4.0642583.270.9326.5693.813.0999.4870.73

4.4345892.390.9524.2691.124.2199.7679.07

4.1349695.431.0328.7593.433.5099.1080.49

4.1051492.991.0726.3193.244.22100.0078.95

4.1149080.900.9726.9093.684.9799.7780.53

3.5334479.660.6831.8794.773.59100.0081.97

4.1650890.981.0129.4395.752.7798.7262.86

4.1754592.981.0826.9294.893.1499.4182.35

4.1650795.101.0125.8294.412.8099.3560.61

4.8654093.171.0727.5993.472.7799.8070.21

5.0655284.381.1027.5695.153.1098.6369.23

4.0345372.690.9026.0391.944.5099.0560.42

4.1552986.531.0522.4091.523.8498.5868.42

3.9451591.011.0225.4494.882.5699.3673.91

4.1255289.141.1025.7092.653.8795.5266.67

4.4259790.181.1826.9493.033.7699.2873.81

3.0543778.810.8723.0594.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 职业教育 > 中职中专

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1