本帖最后由 生统家园推荐 于 2010-8-31 15:12 编辑
data survey; input id diet exer hours xwk $ educ $;
total_miss=nmiss(diet,exer,hours)+cmiss(xwk,educ);
datalines;
1 1 . 1 3 1
1 . 2 1 4 2
1 . 4 . . .
1 1 5 2 3 .
2 . 9 2 3 .
2 5 9 2 4 .
2 . 3 . 5 3
3 2 . . . .
;
如果不要后面的CMISS也可以得出需要的结果
但是CMISS与NMISS的却别是什么呢
看看下面的程序:
data survey;
input id diet exer hours xwk $ educ $;
total_miss=nmiss(diet,exer,hours,xwk,educ);
datalines;
1 1 . 1 A .
1 . 2 1 4 2
1 . 4 . . .
1 1 5 2 3 .
2 . 9 2 3 .
2 5 9 2 4 .
2 . 3 . 5 3
3 2 . . . .
;
结果是不一样的
在SAS 官方网站说明如下:
argument specifies a constant, variable, or expression. Argument can be either a character value or a numeric value.
A character expression is counted as missing if it evaluates to a string that contains all blanks or has a length of zero.
A numeric expression is counted as missing if it evaluates to a numeric missing value: ., ._, .A, ... , .Z.
The CMISS function does not convert any argument. The NMISS function converts all arguments to numeric values.
|