Announcement

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

  • How to enter year intervals for panel data

    Hello,

    I have a panel data of 40 years further sub-divided into 5 years. Therefore, 8 time periods in total like 1970-1975, 1975-1980 etc. My question is Stata takes these as string variables, due to which I can't set my data as a panel. What should I be doing to incorporate such year intervals in my data into Stata?

    I am a fairly new user and would appreciate the help.

    Thank you!

  • #2
    It would have been easier had you posted an example of your data (using the -dataex- command, see FAQ #12), and then you would be able to get a concrete answer tailored to your data. That being impossible, here is some general guidance.

    1. Take your string time variable and -split- it into two time variables, with the -parse("-")- option and the -destring- option.

    2. You now have two new variables containing, respectively, the first and last year in each interval. You could use either of those as the time variable in your -xtset- command, whichever makes more sense for what you are doing. (Or you could average them and use that.)

    By the way, do they really look like 1970-1975, 1975-1980? If so, the 1975 data is represented twice, whereas years that are not multiple of 5 would be represented only once. That could lead to some very strange and probably invalid results. Are you sure they aren't more like 1970-1974, 1975-1979?

    Comment


    • #3
      Hi Clyde,

      Thanks for your reply. I will try what you said. Also, yes that's how they look like. I have consulted existing literature too.

      Comment

      Working...
      X