Announcement

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

  • Changing data structure (Expanding observations) with previous value

    Dear all,

    Thanks in advance for any suggestions and supports!
    I am currently working on a dataset with three variables that looks like the following

    group year id
    1 2000 1
    1 2000 2
    1 2001 5
    2 2007 1
    2 2007 3
    2 2008 4
    2 2010 5
    This dataset contains random records of ids in different groups at different years. I am hoping to expand the dataset to track the historical ids (of all previous years) of groups in each year.
    The new data structure should ideally look like the following
    group year id
    1 2000 1
    1 2000 2
    1 2001 1
    1 2001 2
    1 2001 5
    2 2007 1
    2 2007 3
    2 2008 1
    2 2008 3
    2 2008 4
    2 2010 1
    2 2010 3
    2 2010 4
    2 2010 5

    I have tried to use suggestions from this link: https://stats.idre.ucla.edu/stata/fa...time-variable/.
    However, my dataset is not exactly a panel dataset. Does anyone have suggestions for this issue? I would appreciate any advice.
    This question is cross-posted in the General forum too.
    Last edited by Nathan Han; 24 Nov 2020, 22:45.

  • #2
    See https://www.statalist.org/forums/for...previous-value

    There is no reason to post this question in the Mata forum (unless you did that accidentally).

    Comment


    • #3
      Originally posted by Andrew Musau View Post
      See https://www.statalist.org/forums/for...previous-value

      There is no reason to post this question in the Mata forum (unless you did that accidentally).
      Thanks! I found out the other answer

      Comment

      Working...
      X