【问题标题】:Is there a way of identifying special missing values in a proc format in SAS?有没有办法在 SAS 中以 proc 格式识别特殊缺失值?
【发布时间】:2018-01-19 13:20:03
【问题描述】:

我正在执行类似于以下代码的操作:

 proc format;
 ** for numeric variables;
 value missf
 . = ‘Missing’
 other = ‘Non-Missing’
 ;

 ** for character variables;
 value $missf
 ‘ ‘ = ‘Missing’
 other = ‘Non-Missing’
 ;
 run;

 proc freq data=rawds;
 table _all_ / missing;
 format _character_ $missf. _numeric_ missf.;
 run; 

如您所见,我们的数值格式为missf。但是,我的数据有特殊的缺失值(.A.B.C 等),它们目前不会被标记为缺失,因为格式 missf 只查找 .

我知道我可以在 proc 格式中添加更多行,即做这样的事情,但感觉效率低下:

. = 'Missing'
.a = 'Missing'
.b = 'Missing'
.c = 'Missing'
...
.A = 'Missing'
...
.Z = 'Missing'

有没有一种无需编写 52 行代码(26 个小写字母,26 个大写字母)就可以添加特殊缺失值的方法?

【问题讨论】:

    标签: sas format missing-data


    【解决方案1】:

    缺失值的顺序是._ 最小,然后是常规缺失,.,然后是.A.Z

    value missf ._-.z = 'Missing' other='Non-missing' ;
    

    或者您可以使用 LOW-HIGH 范围来捕获非缺失值和缺失值的 OTHER 情况。

    value missf low-high='Non-missing' other='Missing';
    

    【讨论】:

    • 谢谢!对于其他想知道的人来说,一个普通的“。”也计入该缺失值顺序。所以我所做的就是用value missf ._-.z = 'Missing' 替换value missf . = ‘Missing’,它工作正常。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-27
    • 2021-01-25
    相关资源
    最近更新 更多