Announcement

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

  • Stack Dataset

    Hi,

    I would like to stack this data:
    Code:
    gp    variable    t1    t2
    1    4    .0073855    .0103527
    1    5    .0048235    .0041432
    1    6    .0108743    .0115713
    1    7    .0173722    .021564
    1    8    .0062099    .0059549
    1    9    .0087727    .0044189
    1    10    .0100987    .0148028
    5    1    -.0064746    .0060163
    5    2    -.0106412    .0093637
    5    3    -.0107839    .0100777
    5    4    -.002558    .0074968
    5    5    .0001651    -.007139
    I'd like it to look like that:
    Code:
    t    gp    variable    ret
    1    1    8    .0062099
    1    1    9    .0087727
    1    1    10    .0100987
    1    5    1    -.0064746
    1    5    2    -.0106412
    1    5    3    -.0107839
    1    5    4    -.002558
    1    5    5    .0001651
    1    5    6    .0081774
    1    5    7    .012387
    1    5    8    -.0124707
    1    5    9    -.0053239
    1    5    10    -.0031307
    2    1    1    .0121191
    2    1    2    .0187712
    2    1    3    .0147924
    2    1    4    .0103527
    2    1    5    .0041432
    2    1    6    .0115713
    2    1    7    .021564
    2    1    8    .0059549
    2    1    9    .0044189
    I have tried the following code but I'm losing variables:
    Code:
    stack gp variable t1 t2, into(t)
    Thanks for your help!

  • #2
    Florent:
    this is a sort of double posting.
    See reply at http://www.statalist.org/forums/foru...e-wide-to-long
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment

    Working...
    X