/* 数值型缺失,可赋值点号(.),data步可以用 var = . 或 missing(var)判断 字符型缺失,可赋值0个或多个空格(‘‘ 或‘ ‘等), data步可以用var = ‘‘ 或missing(var)判断 以下是数值型缺失转字符型的例子,但缺失转换后不缺失,易做错。 */ data test; input var; datalines; 1 . ; run; /* 错误转换*/ data test2; set test; var2 = compress(put(var, 8.)); run; proc sql; select count(*) as miss_n from test2 where var2 is missing; quit; /* 正确转换*/ data test3; set test; if missing(var) then var2 = ‘‘; else var2 = compress(put(var, 8.)); run; proc sql; select count(*) as miss_n from test3 where var2 is missing; quit;
时间: 2024-11-10 08:37:09