Announcement

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

  • expand data

    Dear Stata users,

    I have a panel database of countries observed on a yearly basis from 2004 to 2018, I want to expand the observations to 2019!

    I would be grateful if you could help me. Thanks

  • #2
    You don't show example data, but assuming there is a variable called country, and the data are in long layout, with time marked by a variable called year:

    Code:
    isid country year, sort
    expand 2 if year == 2018
    by country year, sort: replace year = year + _n - 1
    Now, each country has an observation for year 2019. But the values of all the other variables for year 2019 observations are copies of the values for 2018. If that is not what you want, then you will need to write additional code to modify them to suit your needs.

    Comment


    • #3
      Thank you Clyde, I appreciate your help.

      Comment

      Working...
      X