Announcement

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

  • How to add an extra year to an existing dataset

    Dear members
    I have a dataset spanning from 2005-2019 and I would like to add 2004 to the year variable by company_id to append the 2004 companies data to the existing dataset.

    what’s stata command to achieve the above task ?
    thanks

  • #2
    If I understand this correctly your main dataset already has a year variable. Even if your 2004 dataset has no year variable, you just need to go within that dataset


    Code:
    gen year = 2004
    and then append, Naturally use a different variable name if your main dataset is using Year or something else.

    Not quite equivalent is to append any way and go then go in the combined dataset

    Code:
    replace year = 2004 if year == .
    That''s not quite equivalent if there are missing values in the main dataset.

    Comment


    • #3
      Thanks Nick for your help. I thought it was more complicated
      than this .

      Comment

      Working...
      X