SPSS Statistics

SPSS Statistics

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

 View Only
Expand all | Collapse all

Restructuring data from long to wide but one variable group not transposing properly

  • 1.  Restructuring data from long to wide but one variable group not transposing properly

    Posted Thu February 23, 2023 02:13 PM

    I have a dataset with 40 timepoints that I am trying to restructure from long to wide format. Everything worked smoothly except for one group of variables will not transpose properly. At each time point, I asked participants which people were present during a social interaction they had and to "select all that apply". This resulted in the variable set of 12 variables to categorize groups of people (e.g., Present_None Present_Partner Present_Parent Present_CloseFam) and there is one additional variable for text input (Present_Other_TEXT). After restructuring from wide to long, the text variable properly transposed such that the response is properly linked to each timepoint (meaning there are 40 distinct Present_Other_TEXT variables in total), as did all other variables in the dataset, but it there is only one set of the other select-all-that-apply variables. When I look at the values, it looks like all of the responses were collapsed into each of the "Present_" items. For example, if at all over the course of the 40 timepoints User 13 selected the Present_Parent item, it is coded as 1. So then I've wound up with a clump of data like this that isn't separated by timepoints like everything else:

    Why is this happening to these items only and what can I do about it? Here is my restructuring syntax for reference:

    SORT CASES BY user .
    CASESTOVARS
      /ID=user
      /GROUPBY=INDEX.



    ------------------------------
    Rachel Bock
    ------------------------------



  • 2.  RE: Restructuring data from long to wide but one variable group not transposing properly

    Posted Fri February 24, 2023 11:08 AM

    In case anyone else stumbles upon this, the problem ended up being that since it was a select all that apply item, non-clicked boxes were coded as missing, not 0. Once I recoded sys-missing to 0's the problem resolved itself.



    ------------------------------
    Rachel Bock
    ------------------------------



  • 3.  RE: Restructuring data from long to wide but one variable group not transposing properly

    Posted Fri February 24, 2023 11:24 AM

    Thanks for the update. I hadn't had a chance yet to try and figure out what could be happening. Good thing; you solved it all by yourself! :)



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