Announcement

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

  • Struggling with reshape

    Hi, I have data where i am looking at IDs, a test for different genes and extra information. I am trying to convert this into wide format so that for each ID i have the results of each gene test with the extra information attached. So far i have created a status variable so the data (simplified) has this form:

    ID Gene ExtraInfo Status
    1 1 1 Y
    2 1 2 Y
    3 1 3 Y
    ​​​​​​​1 2 4 Y
    ​​​​​​​3 2 6 Y

    I want to be able to reshape the data so that it has the following form:

    ID Gene1 ExtraInfo1 Gene2 ExtraInfo2
    1 Y 1 Y 4
    2 Y 2
    ​​​​​​​3 Y 3 Y 6

    Is it possible to do this?

    Thanks
    Cydney

  • #2
    What did you try? Consider this:


    Code:
    clear 
    input ID Gene ExtraInfo str1 Status
    1 1 1 Y
    2 1 2 Y
    3 1 3 Y
    1 2 4 Y
    3 2 6 Y
    end 
    
    reshape wide Status ExtraInfo, i(ID) j(Gene) 
    
    list
    
    
    . list
    
         +----------------------------------------------+
         | ID   ExtraI~1   Status1   ExtraI~2   Status2 |
         |----------------------------------------------|
      1. |  1          1         Y          4         Y |
      2. |  2          2         Y          .           |
      3. |  3          3         Y          6         Y |
         +----------------------------------------------+
    Please note as -- in FAQ Advice #12 -- the permanent requests to use CODE delimiters and dataex output for data examples.


    Comment


    • #3
      That worked perfectly thank you very much!

      Comment


      • #4
        Good, and you're welcome, but for future posts note that the rhetoric of "struggle" is a little over the top with no evidence of your trying anything at all.

        Comment

        Working...
        X