SPSS Statistics

SPSS Statistics

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

 View Only
  • 1.  Intergrate different lines into 1 variable

    Posted Sun May 23, 2021 07:19 AM
    Hi ,

    In dataset, I have one categorical variable(7 categories), but in SPSS it is divided into 7 lines(Variables).

    What prevents you from living as your gender identity?
    Variable 1 My family (1=YES) (only 1 label"1=yes". no other lables. )
    Variable 2 My friends(1=YES)
    Variable 3 My colleagues(1=YES)
    Variable 4 My child(1=YES)
    Variable 5 My parents(1=YES)
    Variable 6 stress(1=YES)
    Variable 7 prior experience(1=YES)


    I was trying to recode them into a new Variable A29 with 7 categories.
    Variable A29(1=Family, 2=friends,3=colleagues, 4=child, 5= parents, 6= stress, 7 =prior experience)

    I ran syntax as below:
    COMPUTE A29 = 0.
    IF (Q29_1=1) A29=1.
    IF(Q29_2=1) A29=2.
    IF (Q29_3=1) A29=3.
    IF (Q29_4=1) A29=4.
    IF (Q29_5=1) A29=5.
    IF (Q29_6=1) A29=6.
    IF (Q29_7=1) A29=7.
    IF (Q29_8=1) A29=8.
    IF (Q29_9=1) A29=9.

    But nothing came up in A29.


    Could you please help solve this problem?
    Many thanks and best wishes,
    Scarlett


    ------------------------------
    yi wang
    ------------------------------

    #SPSSStatistics


  • 2.  RE: Intergrate different lines into 1 variable

    Posted Sun May 23, 2021 12:39 PM
    Your code is correct, but the data have not been passed  yet, so you don't see the values in the Data Editor.  Run any procedure, and you will see the values.  EXECUTE is a procedure that just passes the data.

    However, I have some concerns about this.
    First, you could write the code more compactly like this.
    vector v =Q29_1 to Q29_9.
    compute A29 = 0.
    loop #i = 1 to 9.
    if v(#i) = 1 A29 = #i.
    end loop.
    exec.

    While this makes little difference for this small problem, writing it in loop form reduces the chance of making an error, and that might matter in more complex situations.

    More importantly, is this really the logic you want?  Your output variable will only reflect the highest Q29 variable.  It seems to me that a multiple response set would be more natural for analysis (and easier to construct).  See Analyze > Tables > Multiple Response Sets and then Custom Tables to pursue this.

    ------------------------------
    Jon Peck
    ------------------------------



  • 3.  RE: Intergrate different lines into 1 variable

    Posted Sun May 23, 2021 03:01 PM
    Hi,

    Thank you so so much!! You are right!!!
    And………………Sorry I have another question. 

    As you can see below, there are so many multiple choices in my dataset. I was trying to intergrate those choices into 1 new variable, so that I could identify who did not respond to that multiple choices question at all. 

    For example, the participant circled with red in the screenshot did not respond to Q30. 



    However, I used Data--Tables--Define multiple response data set, it did not create a new variable in the Variable View. So how could I achieve this? I mean cleaning data whose response rate was below 50%.

    Many thanks and best wishes,
    Scarlett

    ------------------------------
    Scarlett
    ------------------------------



  • 4.  RE: Intergrate different lines into 1 variable

    Posted Sun May 23, 2021 03:10 PM
    Multiple response sets are not regular variables.  They can be used  only with CTABLES or GGRAPH, but they will not appear in the Data Editor, although you could create a table with the id as the row variable and the MR set as the columns.

    However, your original code or the modified version would create a new variable that has value 0 for any case that did not select any of the choices.  Then you could do a temporary select on that condition and use LIST or Reports > Case Summaries to show just those cases.

    ------------------------------
    Jon Peck
    ------------------------------



  • 5.  RE: Intergrate different lines into 1 variable

    Posted Tue May 25, 2021 04:12 AM

    Hi, 
    Thank you so much! 
    Sorry I forgot to reply cause I fell asleep while working on my "lovely " data.

    Many thanks and best wishes!




    ------------------------------
    yi wang
    ------------------------------