我有一个包含Color列的数据集。我在这一栏中有黑白红的价值观。当我试图计算表格列的频率时,我得到黑色,白色和红色的结果。但我还需要显示绿色和蓝色的零频率。如果我在Color Color列中没有这两种颜色,我怎么能这样做呢?
答案 0 :(得分:1)
最简单的方法是使用PROC MEANS
,如下所示:
proc format;
value colors 1 = "Black"
2 = "White"
3 = "Red"
4 = "Green"
5 = "Blue";
run;
data mytable;
input color;
format color colors.;
datalines;
1
2
1
3
;
proc means data=myTable completetypes;
class color / preloadfmt;
run;
另一种方法是使用PROC TABULATE
,指定包含所有可能值的附加输入表(classdata
参数),如下所示:
data allColors;
input color;
format color colors.;
datalines;
1
2
3
4
5
;
proc tabulate data=mytable classdata = allColors;
class color;
table color / misstext = "0";
run;
结果:
答案 1 :(得分:-1)
使用缺少选项:
MISSING
treats missing values as a valid nonmissing level for all TABLES variables.
Displays missing levels in frequency and crosstabulation tables and includes
them in computations of percentages and statistics.