PROC MEANS - 保存结果中显示的 table 而不是输出数据中

PROC MEANS - Save table shown in results and not in Output Data

我有以下代码来生成描述性统计数据:

proc means data=sashelp.cars;
    var Horsepower Weight Length;
    output out =  cars_stats mean = std = /autoname;
run;

我希望在稍后将 table 导出到 Excel 时,在输出数据的结果选项卡中显示 table。

目前我在结果中得到以下内容:

但是我在“输出数据”选项卡中得到了这个。

如何从输出数据的结果中得到 table?

ods 救援!

首先运行你的代码是这样的:

ods trace on;
proc means data=sashelp.class;
    var Weight Height;
    output out =  class_stats mean = std = /autoname;
run;
ods trace off;

然后查看日志:

Output Added:
-------------
Name:       Summary <-- We want this bit
Label:      Summary statistics
Template:   base.summary
Path:       Means.Summary
-------------

然后再运行这样:

ods select none;
ods output summary = class_summary;
proc means data=sashelp.class;
    var Weight Height;
    output out =  class_stats mean = std = /autoname;
run;
ods select all;

这种方法允许您捕获任何过程的任何输出,这些输出通常会在结果区域中显示为 sas 数据集。

Proc MEANS 与选项 STACKODSOUTPUT 将产生相同的期望 table.

ods select none;
proc means data=sashelp.cars stackodsoutput;
    var Horsepower Weight Length;
    ods output summary = cars_stats_stacked;
run;
ods select all;