Announcement

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

  • Creating additional ten years for each decade with same info for each county

    Hello,

    I have data where it has information for the years 1980, 1990, 2000, 2010, and 2020. But, the value of the desired variables remain the same for every decade from 2000-to 2010 and 2010-to 2020. To merge with my panel ( from 2000-2020 ) data I need to create additional years from 2000, 2001, 2002, 2003, 2004, 2005 to 2020 for each county with the same variable for each decade. Just with the modification of creating additional 10 years with the same info for each county.

    The dataset has thousands of observations. So, if I do it by hand, it will take a lot of time. Is there any way I can do it by coding it?

    dataex statefips cntyfips year

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float statefips int cntyfips float year
    1  13 90
    1  13 20
    1  13 00
    1  13 10
    1  13 80
    1  17 00
    1  17 20
    1  17 80
    1  17 90
    1  17 10
    1  21 80
    1  21 90
    1  21 10
    end

  • #2
    Tariq, is this what you need?

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float statefips int cntyfips float year
    1  13 90
    1  13 20
    1  13 00
    1  13 10
    1  13 80
    1  17 00
    1  17 20
    1  17 80
    1  17 90
    1  17 10
    1  21 80
    1  21 90
    1  21 10
    end
    
    replace year = cond(year<=20, 2000, 1900) + year
    expand 10 if inlist(year, 2000, 2010)
    bys statefips cntyfips year: replace year = year + _n - 1

    Comment


    • #3
      My sincerest apologies for getting back to you so late. Having been under the pressure of a few deadlines I somehow missed the opportunity to thank you for being so generous with your time and accurate suggestion which I was looking for. Much obliged for this kind gesture!

      Comment

      Working...
      X