SPSS Statistics

 View Only
  • 1.  Creating composite variables with conditions

    Posted Tue April 06, 2021 04:33 PM
    Hello, 

    I am trying to figure out how to create a certain kind of composite variable. I have 4 binary variables regarding whether different types of adverse events happened to a person (sample size of 183 people).

    I want to create one binary variable which shows whether ANY adverse event happened to them or not, i.e. if they answered "yes" to any (1 or more) of the above 4 questions, then they are assigned a "yes" in the new, composite variable. If they answered "no" to all 4 events, then they are assigned a "no" in the new variable. 

    I'm sure this is probably simple, but I can't find exact directions for this when searching for creating composite variables or re-coding variables. I'm inexperienced with SPSS. Grateful for any advice.

    ------------------------------
    Sean Nine
    ------------------------------

    #SPSSStatistics


  • 2.  RE: Creating composite variables with conditions

    IBM Champion
    Posted Tue April 06, 2021 05:19 PM
    Just use the ANY function in a COMPUTE:
    compute hasadverse = any(1, e1 to e4).
    (or list the event variables explicitly if they are not consecutive in the file).
    If the variables are not coded 1/0, you could write, for example,
    any("yes", e1 to e4).
    or other variants.  Look at the help for the any function in the Transform > Compute dialog.

    --





  • 3.  RE: Creating composite variables with conditions

    Posted Tue April 06, 2021 05:39 PM
    There are many ways to do this. One quick and easy way would be to use the SUM function. Here is a small example.

    data list free /b1 to b4 (4F1).
    begin data.
    1 0 1 1
    0 0 0 0
    0 . 1 1
    . . . 1
    1 0 0 0
    0 . . 0
    . . . .

    end data.

    compute x=sum(b1 to b4).
    recode x (0=0) (1 thru 4=1) into indicator.
    list.


    The new variable INDICATOR is 1 if any of the 4 were 1, 0 if not (except if b1 thru b4 are missing).

    Hope that helps.


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