Announcement

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

  • Messed up order of variables in reshape

    Hi,

    I am trying to reshape my data to wide, but then I reshape the order is messed up so tube"j" contains differenet tube information since there is lacking data for some ids (only 3 different tubes for some).

    Is there a way to create new observations containing id and tube, but missing data in Assay to help the order?

    Thank you for your inputs!

    /Anne



    Current output:
    Click image for larger version

Name:	current output.png
Views:	2
Size:	12.8 KB
ID:	1728210


    Desired output:
    Click image for larger version

Name:	desired output.png
Views:	2
Size:	4.6 KB
ID:	1728211



    clear
    input str2 id str4 tube str3 Assay
    "1" zym Il2
    "1" zym Il4
    "1" zym IL6
    "1" lps Il2
    "1" lps Il4
    "1" lps IL6
    "2" null Il2
    "2" null Il4
    "2" null IL6
    "2" zym Il2
    "2" zym Il4
    "2" zym IL6
    "2" lps Il2
    "2" lps Il4
    "2" lps IL6
    "2" null Il2
    "2" null Il4
    "2" null IL6
    "2" cd3 Il2
    "2" cd3 Il4
    "2" cd3 IL6
    "3" zym Il2
    "3" zym Il4
    "3" zym IL6
    "3" lps Il2
    "3" lps Il4
    "3" lps IL6
    "3" cd3 Il2
    "3" cd3 Il4
    "3" cd3 IL6
    end

    bysort id (tube): gen j=_n

    reshape wide tube Assay, i(id) j(j)

  • #2
    Duplicate post. Please follow https://www.statalist.org/forums/for...les-in-reshape if interested.

    Comment

    Working...
    X