SAS中保存统计分析步的结果至数据集中.doc
《SAS中保存统计分析步的结果至数据集中.doc》由会员分享,可在线阅读,更多相关《SAS中保存统计分析步的结果至数据集中.doc(4页珍藏版)》请在冰点文库上搜索。
SAS中保存统计分析步的结果至数据集中
在我们做完统计分析步(如procreg等)后,有时想要将某些结果数据保存在数据集中,较为简单的常用方法有下面三种:
使用proc步结果输出选项,使用output语句,使用odsoutput的方法。
下面以较为常用的procreg步进行举例说明:
1.使用procreg步结果输出选项
在procreg;的options中可以选择outest=选项来产生一个数据集,用于存储参数估计值、模型拟合的相关统计值等;同时还有edf、outseb、tableout、sse等选项(其他更多选项参见SAShelp文档),可以将你想要的统计分析结果存储于outest=生产的数据集中。
·OUTEST=outputsadatasetthatcontainsparameterestimatesandothermodel�0�3tsummarystatistics
·EDFoutputsthenumberofregressors,theerrordegreesoffreedom,andthemodelR2totheOUTEST=dataset
·OUTSEBoutputsstandarderrorsoftheparameterestimatestotheOUTEST=dataset
·TABLEOUToutputsstandarderrors,con�0�3dencelimits,andassociatedteststatisticsoftheparameterestimatestotheOUTEST=dataset
例:
procregdata=sashelp.classoutest=result1edfsse;
modelweight=height;
quit;
数据集work.result1如下:
2.使用procreg步的output语句
在procreg步中,output语句语法如下:
output<...keyword=names>;
使用output语句可保存模型拟合后,模型诊断检验的一些数据结果。
由于procreg中可以有多个model语句,output对离它最近的一个model有效,并且,需至少定义一个keyword=names选项。
keyword=包括cookd=、h=、p=、r=等选项(其他更多选项参见SAShelp文档)。
·COOKD=�0�2�0�2�0�2Cook’sDin�0�4uencestatistic
·H=�0�2�0�2�0�2leverage
·PREDICTED|P=�0�2�0�2�0�2predictedvalues
·RESIDUAL|R=�0�2�0�2�0�2residuals,calculatedasACTUALminusPREDICTED
例:
procregdata=sashelp.class;
modelweight=height;
outputout=result2p=p_valuer=residuals;
quit;
数据集work.result2如下:
3.使用odsoutput的方法
使用odsoutput可以将统计分析的结果的任意部分存入数据集中。
如对
procregdata=sashelp.class;
modelweight=height;
quit;
在SAS的results窗口下,可以看到procreg步结果列表
另外,使用odstrace可以在log窗口中查看输出结果,如下
odstraceon;
procregdata=sashelp.class;
modelweight=height;
quit;
odstraceoff;
如想保存AnalysisofVariance的结果,其属性名为ANOVA,代码如下:
odsoutputanova=result3;
procregdata=sashelp.class;
modelweight=height;
quit;
odsoutputclose;
数据集work.result3如下:
参考文献
1.SASSTAT9.2User’sGuide(2dEdition)