返回首页

spss中使用syntax操作missing值

时间:2012-12-31 23:53来源:知行网www.zhixing123.cn 编辑:麦田守望者

PROBLEM:

 

    When using IF commands, if I try to assign a missing value to a numeric variable by using a period (".") as in the following incorrect command syntax,

     

      IF (OLDVAR = 9) NEWVAR=. .
    SPSS sees the period as the command terminator, and the missing value doesn't get assigned appropriately. Also, if I try to recode an existing numeric missing value into something else using a period (".") as in the following incorrect command syntax,

     

      IF (OLDVAR = .) NEWVAR = 4.
    that doesn't work either.

SOLUTION:

 

Numeric Variables

 

    Apparently, SPSS doesn't use the period (".") as an actual numeric missing value, only for display (output) purposes.

    To create a new numeric missing value, use "$sysmis" after the equal sign, as in this example:

     

      IF (OLDVAR = 9) NEWVAR = $SYSMIS.
    To use a numeric missing value in an evaluation expression, use the MISSING(arg) function, as in this example:

     

      IF MISSING(OLDVAR) NEWVAR = 4.

Character (String/Alphanumeric) Variables

 

Missing values in string variables are handled in a more straightforward manner.

To create a new string missing value, use quotation marks (' ', or " ") after the equal sign, as in this example:

 

    IF (OLDVAR = 'X') NEWVAR = " ".

To use a string missing value in an evaluation expression, use quotes similar to the above, as in this example:

 

IF (OLDVAR=' ') NEWVAR = "XYZ".

------分隔线----------------------------
标签(Tag):SPSS
------分隔线----------------------------
推荐内容
猜你感兴趣