SPSS Statistics

 View Only
  • 1.  Split observations / variables

    Posted Mon April 05, 2021 02:45 PM
    Hello

    I am blocked
    I'm looking for how to separate the observations of a variable so that each observation becomes a new binary variable with 1 for saying yes and 0 for no.

    Contraceptive method variable example
    * ID. * * Method_contr *
    1.        IUD condom pill
    2.        IUD
    3.       Implant other
    4.       Mama condom
    5.       calendar other 

    These are multiple choice questions with odk (select_multiple). I'm trying to figure out how to separate it so that each method becomes a binary variable with 1 to say yes and 0 no

    Thank you

    ------------------------------
    Tesky Koba
    ------------------------------

    #SPSSStatistics


  • 2.  RE: Split observations / variables

    Posted Mon April 05, 2021 02:59 PM

    Perhaps use RECODE:

    RECODE Method_contr (1=1) (MISSING,SYSMIS=SYSMIS) (ELSE=0) into Condom_Pill.
    RECODE Method_contr (2=1) (MISSING,SYSMIS=SYSMIS) (ELSE=0) into IUD.
    RECODE Method_contr (3=1) (MISSING,SYSMIS=SYSMIS) (ELSE=0) into Implant_Other.
    ... etc.
    EXECUTE.




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



  • 3.  RE: Split observations / variables

    Posted Tue April 06, 2021 03:32 AM
    Hi,
    I am not completely sure, and it also depends on how you have exported your ODK data. I think ODK stores multiple choice variables in csv files  in a text string where each value is separated from the next with a space. If that is so, then you can pick out the first answer by extracting its value using the char.substr function and convert it to a number. That is char.subsrt(method,1,1) will  pick out the first, char.substr(method,3,1) will pick out the second and so on. You also need to convert to a number, and then check what answer it is. Thus, compute value1=number(char.substr(method,1,1),F2.0). 
    And so on. A more general method is obviously creating a loop and search for the spaces.  
    I probably have a macro around somewhere designed for CSPro output that more or less does the conversion. 
    Note that you can either use multiple dichotomies or multiple categories in multiple response sets in SPSS. 
    hth

    ------------------------------
    Jon
    ------------------------------



  • 4.  RE: Split observations / variables

    Posted Tue April 06, 2021 07:58 AM
    Could you post a snippet of your data (as SPSS sees it), so I can see whether we're dealing with separate variables or one string that must be broken apart?

    If it's the latter, you could use LOOP to go through them along with a NUMBER function and substrings, or you could simply WRITE the string to a text file and use GET DATA or DATA LIST to read it back in as separate numeric variables. (Perhaps a "brute force" method but it gets the job done.) Then, as I already said, you can RECODE them into binary variables.

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