问题描述
在 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 变量中的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!