如何在 SAS 中获取 PROC REPORT 以显示没有观察值的 ACROSS 变量中的值? [英] How can I get PROC REPORT in SAS to show values in an ACROSS variable that have no observations?

查看:18
本文介绍了如何在 SAS 中获取 PROC REPORT 以显示没有观察值的 ACROSS 变量中的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 SAS 中使用 PROC REPORT,如果某个 ACROSS 变量有 5 种不同的值可能性(例如,1 2 3 4 5),但在我的数据集中,没有观察到该变量等于 5,如何让报告显示 5 列并为具有该值的观察数显示 0?

Using PROC REPORT in SAS, if a certain ACROSS variable has 5 different value possibilities (for example, 1 2 3 4 5), but in my data set there are no observations where that variable is equal to, say, 5, how can I get the report to show the column for 5 and display 0 for the # of observations having that value?

目前我的 PROC REPORT 输出只是不显示那些没有观察值的列.

Currently my PROC REPORT output is just not displaying those value columns that have no observations.

推荐答案

当事关紧要的时候,你可以做一些这样的小技巧.请注意,SASHELP.CLASS 的 SEX 变量没有缺失:

When push comes to shove, you can do some hacks like this. Notice that there are no missing on SEX variable of the SASHELP.CLASS:

proc format;
  value $sex 'F' = 'female' 'M' = 'male' 'X' = 'other';
run;

options missing=0;
proc report data=sashelp.class nowd ;
  column age sex;
  define age/ group;
  define sex/ across format=$sex. preloadfmt;
run;
options missing=.;
/*
                  Sex
    Age  female  male    other
     11       1       1       0
     12       2       3       0
     13       2       1       0
     14       2       2       0
     15       2       2       0
     16       0       1       0
*/

这篇关于如何在 SAS 中获取 PROC REPORT 以显示没有观察值的 ACROSS 变量中的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆