SPSS Statistics

SPSS Statistics

Your hub for statistical analysis, data management, and data documentation. Connect, learn, and share with your peers! 

 View Only
  • 1.  handling missing values in comparisons

    Posted Tue May 10, 2022 11:34 AM

    Hi,

     

    A "quick" question...

     

    I have the following code:

     

    do if (refgroup <> compgroup).

    if (pctdiff_se > 0) pctdiff_t = pctdiff / pctdiff_se.

    end if.

     

    When either refgroup or compgroup are missing, either system or user defined, the IF is not executed.

     

    You can see the behavior here:

     

    ** start code**.

    data list / a 1-1 b 2-2.

    begin data.

    12

    1

    2

    11

    22

    13

    23

    33

    end data.

    missing values b(3).

    if (a<>b) x = 1.

    do if (a=b).

    compute y = 1.

    else.

    compute y = 2.

    end if.

    list var = all.

    ** end code.

     

    Is there a way to "allow" for this comparison to take place without converting the missing values into not-missing?

     

    Thanks!

     

    E.

     



    This e-mail and any files transmitted with it may contain privileged or confidential information. It is solely for use by the individual for whom it is intended, even if addressed incorrectly. If you received this e-mail in error, please notify the sender; do not disclose, copy, distribute, or take any action in reliance on the contents of this information; and delete it from your system. Any other use of this e-mail is prohibited.


    Thank you for your compliance.



    #SPSSStatistics


  • 2.  RE: handling missing values in comparisons

    Posted Tue May 10, 2022 11:42 AM
    The reason is that the result is indeterminate in that case  (three- valued logic).
    What do you want to do in that case?  There is a MISSING function that can be used to control the condition.
    --





  • 3.  RE: handling missing values in comparisons

    Posted Tue May 10, 2022 11:52 AM
    Maybe the VALUE function?

    from the CSR:
    VALUEVALUE(variable). Numeric. Returns the value of variable, ignoring user missing-value definitions for variable, which must be a numeric variable name or a vector reference to a variable name.

    ```
    data list / a 1-1 b 2-2.
    begin data.
    12
    1
    2
    11
    22
    13
    23
    33
    end data.

    missing values b(3).
    if (a<>b) x = 1.
    do if (value(a)=value(b)).
    compute y = 1.
    else.
    compute y = 2.
    end if.
    list var = all.

    ** end code.
    ```

    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------