Announcement

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

  • Growth

    Hi, I have an unbalanced panel data with id year (1997-2003) and I would like to calculate the growth in the population for 5 years. I was trying to use this formula (population [t = 0] – population [t = -5])/population [t = -5], but it does not work. Then I tried using lags, but I don`t know how that works. Could someone help me? Thank you!

  • #2
    Code:
    xtset id year
    gen growth = (population-L5.population)/L5.population

    Comment


    • #3
      Thank you! I have tried this, but somehow stata doesnt know how big an id is and it goes through every observations minus 5 years without realising that the specific id was over and it makes everything wrong. Do you have a solution for that maybe?

      Comment


      • #4
        I have no idea what you're talking about. Use -dataex- to post an example of your data that exhibits this problem and I will try to troubleshoot it.

        If you are running version 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

        Comment

        Working...
        X