gpt4 book ai didi

sas - 计算 0 值的个数

转载 作者:行者123 更新时间:2023-12-04 22:26:50 25 4
gpt4 key购买 nike

类似于here ,我可以计算缺失观察值的数量:

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;

但是我怎样才能计算出 0 的观察值的数量?

最佳答案

如果您想要计算为 0 的观察值的数量,您需要使用 proc tabulateproc 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;

类似的东西。显然要小心 _numeric_ 因为它都是数字变量,如果你有很多它们可能会很快变得困惑......

关于sas - 计算 0 值的个数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30583808/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com