Announcement

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

  • Converting biennial data to yearly (panel)

    What is the easiest way to convert a biennial data to yearly data? I have a biennial data for each of the 50 states from 1976-2022. But I want to make it yearly for each state.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int year str20 state float voted
    1976 "ALABAMA"     984181
    1978 "ALABAMA"     642279
    1980 "ALABAMA"    1013626
    1982 "ALABAMA"     961019
    1984 "ALABAMA"    1148574
    1986 "ALABAMA"    1115517
    1988 "ALABAMA"    1178298
    1990 "ALABAMA"    1015869
    1992 "ALABAMA"    1602536
    1994 "ALABAMA"    1115019
    1996 "ALABAMA"    1468693
    1998 "ALABAMA"    1215179
    2000 "ALABAMA"    1438994
    2002 "ALABAMA"    1268802
    2004 "ALABAMA"    1792759
    2006 "ALABAMA"    1140152
    2008 "ALABAMA"    1855268
    2010 "ALABAMA"    1367747
    2012 "ALABAMA"    1933630
    2014 "ALABAMA"    1080880
    2016 "ALABAMA"    1889685
    2018 "ALABAMA"    1659895
    2020 "ALABAMA"    2051659
    2022 "ALABAMA"    1343710
    1976 "ALASKA"      118208
    1978 "ALASKA"      124187
    1980 "ALASKA"      154618
    1982 "ALASKA"      181084
    1984 "ALASKA"      206437
    1986 "ALASKA"      180277
    1988 "ALASKA"      192955
    1990 "ALASKA"      191647
    1992 "ALASKA"      239116
    1994 "ALASKA"      208240
    1996 "ALASKA"      233700
    1998 "ALASKA"      223300
    2000 "ALASKA"      274393
    2002 "ALASKA"      227725
    2004 "ALASKA"      299996
    2006 "ALASKA"      234645
    2008 "ALASKA"      316978
    2010 "ALASKA"      254335
    2012 "ALASKA"      289804
    2014 "ALASKA"      279741
    2016 "ALASKA"      308198
    2018 "ALASKA"      282166
    2020 "ALASKA"      353165
    2022 "ALASKA"      263610
    end

  • #2
    No need to. Just let Stata know that you have biennial data.

    Code:
    encode state, gen(State)
    xtset State year, delta(2)
    Res.:

    Code:
    . encode state, gen(State)
    
    .
    . xtset State year, delta(2)
    
    Panel variable: State (strongly balanced)
     Time variable: year, 1976 to 2022
             Delta: 2 units

    Comment


    • #3
      Cross-posted at https://www.reddit.com/r/stata/comme...o_yearly_data/

      Please note that it is a request here and a rule on that part of Reddit to tell people about cross-posting.

      The replies on Reddit range from puzzled to bizarre. A suggestion there to reshape wide is hard to understand.

      I support Andrew Musau's suggestion above. You can't get yearly data out of this dataset without interpolation, which in this context is probably a bad idea on several grounds. Were there votes in odd years and what sense does it make to impute or interpolate?

      Perhaps you have other variables for every year, but if so we need to know more about your goals to add to Andrew's advice.

      Comment

      Working...
      X