SAS中保存统计分析步的结果至数据集中

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

SAS中保存统计分析步的结果至数据集中
在我们做完统计分析步(如proc reg等)后,有时想要将某些数据保存在数据集中,较为简单的常用方法有下面三种:使用proc步输出选项,使用output语句,使用ods output的方法。

下面以较为常用的proc reg步进行举例说明:
1.使用proc reg步输出选项
在proc reg ; 的options中可以选择outest= 选项来产生一个数据集,用于存储参数估计值、模型拟合的相关统计值等;同时还有edf、outseb、tableout、sse等选项(其他更多选项参见SAS help文档),可以将你想要的统计分析存储于outest= 生产的数据集中。

•OUTEST= outputs a data set that contains parameter estimates and other model �0�3t summary statistics
•EDF outputs the number of regressors, the error degrees of freedom, and the model R2 to the OUTEST= data set
•OUTSEB outputs standard errors of the parameter estimates to the OUTEST= data set
•TABLEOUT outputs standard errors, con�0�3dence limits, and associated test statistics of the parameter estimates to the
OUTEST= data set
例:
proc reg data=sashelp.class outest=result1 edf sse;
model weight=height;
quit;
数据集work.result1如下:
2.使用proc reg步的output语句
在proc reg步中,output语句语法如下:
output <out=SAS-data-set >< keyword=names > < . . . keyword=names > ;
使用output语句可保存模型拟合后,模型诊断检验的一些数据。

由于proc reg中可以有多个model语句,output对离它最近的一个model有效,并且,需至少定义一个keyword=names选项。

keyword= 包括cookd=、h=、p=、r= 等选项(其他更多选项参见SAS help文档)。

•COOKD= �0�2�0�2 �0�2Cook’s D in�0�4uence statistic
•H= �0�2�0�2 �0�2leverage
•PREDICTED | P= �0�2�0�2 �0�2predicted values
•RESIDUAL | R= �0�2�0�2 �0�2residuals, calculated as ACTUAL minus PREDICTED
例:
proc reg data=sashelp.class;
model weight=height;
output out=result2 p=p_value r=residuals;
quit;
数据集work.result2如下:
3.使用ods output的方法
使用ods output可以将统计分析的的任意存入数据集中。

如对
proc reg data=sashelp.class;
model weight=height;
quit;
在SAS的results窗口下,可以看到proc reg步列表
另外,使用ods trace可以在log窗口中查看输出,如下
ods trace on;
proc reg data=sashelp.class;
model weight=height;
quit;
ods trace off;
如想保存Analysis of Variance的,其属性名为ANOVA,代码如下:
ods output anova=result3;
proc reg data=sashelp.class;
model weight=height;
quit;
ods output close;
数据集work.result3如下:
参考文献
1.SAS STAT 9.2 User’s Guide (2d Edition)。

相关文档
最新文档