如何查看我的 proc 中可用的输出选项?
How do I see what output options are available in my proc?
运行复杂的procs如PROC REG
或PROC GLM
,输出中经常会产生表格window描述回归的结果,另外使用 OUT
或 OUTPUT
选项生成的输出数据集。
如何将这些表输出到 SAS 数据集?
例如,给定PROC REG中的第一个SAS示例(在documentation page上),如何输出拟合优度统计(例如R-Squared)?
为了识别可能的输出数据集,SAS 提供了 ods trace
statement. This asks SAS to write to the log the name (and some details) of each data table it writes to the output. In most cases, this can be saved to a dataset via ods output
.
例如,在问题中提到的 SAS 示例中,您可以这样写:
ods trace on;
proc reg data=baseball;
id name team league;
model logSalary = no_hits no_runs no_rbi no_bb yr_major cr_hits;
run;
ods trace off;
这将在日志中报告 "FitStatistics" 是您想要的输出对象的名称。然后你写:
ods output FitStatistics=fitds;
proc reg data=baseball;
id name team league;
model logSalary = no_hits no_runs no_rbi no_bb yr_major cr_hits;
run;
它将输出 fitds
数据集。
ODS Trace 仅用于确定 table 的名称当然 - 一旦您知道所需的 table 的名称,您可以简单地将该名称与 ods output
以后。
您也经常可以在文档中找到 table 名称的列表;例如,PROC REG 将它们放在 here.
ODS 输出可以放在 run
语句之前的任何位置(因为它是一个全局语句);一个常见的位置就在 run
之前。我个人喜欢把它放在 proc
之前,因为它是一个全局语句,但是 there is some disagreement with that approach.
运行复杂的procs如PROC REG
或PROC GLM
,输出中经常会产生表格window描述回归的结果,另外使用 OUT
或 OUTPUT
选项生成的输出数据集。
如何将这些表输出到 SAS 数据集?
例如,给定PROC REG中的第一个SAS示例(在documentation page上),如何输出拟合优度统计(例如R-Squared)?
为了识别可能的输出数据集,SAS 提供了 ods trace
statement. This asks SAS to write to the log the name (and some details) of each data table it writes to the output. In most cases, this can be saved to a dataset via ods output
.
例如,在问题中提到的 SAS 示例中,您可以这样写:
ods trace on;
proc reg data=baseball;
id name team league;
model logSalary = no_hits no_runs no_rbi no_bb yr_major cr_hits;
run;
ods trace off;
这将在日志中报告 "FitStatistics" 是您想要的输出对象的名称。然后你写:
ods output FitStatistics=fitds;
proc reg data=baseball;
id name team league;
model logSalary = no_hits no_runs no_rbi no_bb yr_major cr_hits;
run;
它将输出 fitds
数据集。
ODS Trace 仅用于确定 table 的名称当然 - 一旦您知道所需的 table 的名称,您可以简单地将该名称与 ods output
以后。
您也经常可以在文档中找到 table 名称的列表;例如,PROC REG 将它们放在 here.
ODS 输出可以放在 run
语句之前的任何位置(因为它是一个全局语句);一个常见的位置就在 run
之前。我个人喜欢把它放在 proc
之前,因为它是一个全局语句,但是 there is some disagreement with that approach.