Announcement

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

  • Reshape data to long - no stub, time in long format

    Dear all,

    I have a dataset in a bit oddly shaped. The time (the data is hourly for 30 years) is already in long format but the panels IDs (more than 250) represent the value of one variable.

    How can I reshape this to a regular long form dataset? Any help will be greatly appreciated. Thank you.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long(year month day hour) double(PL41 ES21 PL32 UKK1 PL34)
    1986 1 1  1 .02459 .21347 .07598 .54705 .16948
    1986 1 1  2 .01484 .20183 .08367 .44395 .16234
    1986 1 1  3 .00972   .198 .09651 .29984 .15206
    1986 1 1  4 .00983 .21373  .0896 .18699 .14123
    1986 1 1  5 .00855 .25338 .08422 .06668 .12608
    1986 1 1  6 .01072 .32322 .09259 .04675 .11158
    1986 1 1  7 .01695 .39983 .09248 .05119 .09848
    1986 1 1  8 .02895 .46698 .11102 .07198 .08874
    1986 1 1  9 .03292 .54667   .124 .17523 .05779
    1986 1 1 10 .02148 .56828 .12769 .28923 .03377
    end
    label values hour hour
    label def hour 1 "00:00:00", modify
    label def hour 2 "01:00:00", modify
    label def hour 3 "02:00:00", modify
    label def hour 4 "03:00:00", modify
    label def hour 5 "04:00:00", modify
    label def hour 6 "05:00:00", modify
    label def hour 7 "06:00:00", modify
    label def hour 8 "07:00:00", modify
    label def hour 9 "08:00:00", modify
    label def hour 10 "09:00:00", modify
    Sincerely,

    Chiara

  • #2
    Code:
    rename (PL41-PL34) whatever= 
    
    reshape long whatever , i(year month day hour) j(id) string

    Comment


    • #3
      Nick Cox, excellent! Worked like a charm! Thank you so much.

      Sincerely,

      Chiara

      Comment

      Working...
      X