Announcement

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

  • How to do reshape from wide to long with big panel data

    Can we use a reshape command to reshape (wide to long) a small part of a data with a large number of variables without dropping other variables?

  • #2
    Apparently you can.
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(id inc2020 inc2021 other)
    101 1 2   42
    102 2 1  666
    103 0 0 2001
    end
    reshape long inc, i(id) j(year)
    list, sepby(id) noobs
    Code:
    . list, sepby(id) noobs
    
      +--------------------------+
      |  id   year   inc   other |
      |--------------------------|
      | 101   2020     1      42 |
      | 101   2021     2      42 |
      |--------------------------|
      | 102   2020     2     666 |
      | 102   2021     1     666 |
      |--------------------------|
      | 103   2020     0    2001 |
      | 103   2021     0    2001 |
      +--------------------------+

    Comment

    Working...
    X