Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Qualtrics Loop and Merge variables into long format

    Hello,
    I ran a Qualtrics loop and merge study, in which participants select a set of fields in the first question. They are then looped through questions about each fields. A simple example from Qualtrics is "A clothing company wants to ask a set of questions about each of its clothing departments. Rather than taking the time to create new questions for men’s clothing, women’s clothing, and children’s clothing, the questions could be created once. Loop & Merge could then automatically repeat the set of questions once for each clothing department the respondent indicated they visited."

    In my study, I had teaching assistant select which teams they supervised, and then answer questions about each team. Unfortunately the way that Qualtrics labels variables in the ensuing dataset isn't user-friendly. Here's a data example. This shows just one record, so there are a lot of variables you don't see here. In this case the TA chose teams1 and 4, indicated by the value of 1 in the variables teams_1 and teams_4.

    They then answered many questions about each team. I just exported two for the sake of this example. Qualtrics added the prefix A1_ to the answers about team 1 and A4_ to the questions about team 4.

    Code:
    clear
    input byte(teams_1 teams_4 A1_inc1w1 A1_inc2w1 A4_inc1w1 A4_inc2w1)
    1 1 4 5 5 5
    end
    label values A1_inc1w1 labels32
    label def labels32 4 "Neutral (neither accurate nor inaccurate)", modify
    label values A1_inc2w1 labels33
    label def labels33 5 "A little accurate", modify
    label values A4_inc1w1 labels77
    label def labels77 5 "A little accurate", modify
    label values A4_inc2w1 labels78
    label def labels78 5 "A little accurate", modify

    Is there an way to use syntax to transform this into a long file where there's a variable team that has the team number and then variables inc1w1 inc2w1 with the corresponding values? I'm familiar with using reshape for variable where there's a suffix, but unsure how to deal with prefixes.

  • #2
    Perhaps this example will start you in a useful direction.
    Code:
    . reshape long A@_inc1w1 A@_inc2w1, i(teams_1 teams_4) j(team)
    (note: j = 1 4)
    
    Data                               wide   ->   long
    -----------------------------------------------------------------------------
    Number of obs.                        1   ->       2
    Number of variables                   6   ->       5
    j variable (2 values)                     ->   team
    xij variables:
                        A1_inc1w1 A4_inc1w1   ->   A_inc1w1
                        A1_inc2w1 A4_inc2w1   ->   A_inc2w1
    -----------------------------------------------------------------------------
    
    . label values A_* .
    
    . list
    
         +------------------------------------------------+
         | teams_1   teams_4   team   A_inc1w1   A_inc2w1 |
         |------------------------------------------------|
      1. |       1         1      1          4          5 |
      2. |       1         1      4          5          5 |
         +------------------------------------------------+

    Comment


    • #3
      The -reshape- command syntax includes an @ which designates the location of prefix, or as you have in your data, infix:

      Code:
      gen long obs_no = _n
      reshape long teams_ A@_inc1w1 A@_inc2w1, i(obs_no) j(team_number)
      Note: the generation of the obs_no variable was done to provide a unique identifier in the i() option. If you already have a variable (or variables) that uniquely identify observations (that you didn't show in your example), then you can use it (them) in the i() option and skip creating obs_no.

      By the way, FWIW, my experience with Qualtrics data is that nothing about it is user friendly, at least not for the "user" who has to manage and analyze the collected data.

      Comment

      Working...
      X