Announcement

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

  • Reshape with 3 variables that uniquely identifies the data.

    Dear Statalisters,

    I have a dataset in long format as follows:

    Code:
    clear
    input float(x y z data)
    1 1 1  15
    1 1 2 -10
    1 1 3   7
    1 2 1   9
    1 2 2   3
    1 2 3   0
    1 3 1   8
    1 3 2  13
    1 3 3   6
    2 1 1  21
    end
    Note that this is just a snippet of the example, and it continues in the pattern above. Thus my data is uniquely identified with 3 variables. I'd like to change this dataset into the following format:

    Code:
    clear
    input float(x y data_1 data_2 data_3)
    1 1 15 -10 7
    1 2  9   3 0
    1 3  8  13 6
    2 1 21   . .
    end
    I'd have used reshape wide data, i(x) j(y) if it was only two variables, but now that there's 3 variables that uniquely identifies the data, I'm at a loss. I'd like to use by, but Stata doesn't allow by with reshape.

    How can I change the dataset to wide? Any help will be appreciated.

  • #2
    the following works for me (and thank you for using -dataex-)
    Code:
    reshape wide data, i(x y) j(z)

    Comment


    • #3
      That was perfect and simple! Never knew I could put more than one variable there. Thank you!

      Comment

      Working...
      X