与这里类似,我可以计算缺失观察的数量:
data dataset;
input a b c;
cards;
1 2 3
0 1 0
0 0 0
7 6 .
. 3 0
0 0 .
;
run;
proc means data=dataset NMISS N;
run;
Run Code Online (Sandbox Code Playgroud)
但我怎样才能计算观察值的数量呢0?
如果您想计算 0 的观测值的数量,您需要使用proc tabulate或proc freq,并进行频率计数。
如果您有很多值并且只想要“0/非 0”,那么使用format.
data have;
input a b c;
cards;
1 2 3
0 1 0
0 0 0
7 6 .
. 3 0
0 0 .
;
run;
proc format;
value zerof
0='Zero'
.='Missing'
other='Not Zero';
quit;
proc freq data=have;
format _numeric_ zerof.;
tables _numeric_/missing;
run;
Run Code Online (Sandbox Code Playgroud)
沿着这些思路。显然要小心,_numeric_因为这都是数字变量,如果你有很多,可能会很快变得混乱......
| 归档时间: |
|
| 查看次数: |
5854 次 |
| 最近记录: |