【问题标题】:creating output from proc freq in SAS从 SAS 中的 proc freq 创建输出
【发布时间】:2017-03-08 12:17:29
【问题描述】:

我在 SAS Enterprise Guide 6.1 中运行以下 SAS 代码,以获取表中所有变量的 null/not null 的一些摘要统计信息。这是通过“结果”选项卡生成所需的信息,该选项卡为每个结果创建一个单独的表格,显示空/非空频率和百分比。

我想做的是将结果放入一个输出数据集中,其中所有变量和统计数据都在一个表中。

proc format;
    value $missfmt ' '='Missing' other='Not Missing';
    value missfmt   . ='Missing' other='Not Missing';
run;
proc freq data=mydatatable;
    format _CHAR_ $missfmt.;
    tables _CHAR_ / out=work.out1 missing missprint nocum;
    format _NUMERIC_ missfmt.;
    tables _NUMERIC_ / out=work.out2 missing missprint nocum;
run;

out1out2 正在生成到这样的表中:

FieldName | Count | Percent
Not Missing | Not Missing | Not Missing

但每个变量只填充一个变量,并且频率计数未显示。

我试图作为输出创建的表是:

field | Missing | Not Missing | % Missing
FieldName1 | 100 | 100 | 50
FieldName2 | 3 | 97 | 3

【问题讨论】:

标签: sas


【解决方案1】:

tables 语句输出选项仅适用于请求的 last 表。 _CHAR_ 解析为(所有字符变量),但它们是单个表,因此您只能得到最后一个请求的表。

您可以通过以下两种方式之一获得。要么使用PROC TABULATE,它更容易处理变量列表;或使用ODS OUTPUT 获取proc freq 输出。两种输出样式都需要一些工作才能完全达到您想要的结构。

ods output onewayfreqs=myfreqs;  *use `ODS TRACE` to find this name if you do not know it;
proc freq data=sashelp.class;
  tables _character_;
  tables _numeric_;
run;
ods output close;

【讨论】:

  • 谢谢,我是 SAS 新手,因此了解可用的不同选项会很有帮助。我使用ods outputproc sql 的组合想出了一个混乱的解决方案!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-07
  • 1970-01-01
  • 1970-01-01
  • 2018-01-03
相关资源
最近更新 更多