Announcement

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

  • Creating observations between election years using Manifesto Project Data.

    Hello. I am a second year political science student in need of help!

    I need to create yearly observations for each political party in the manifesto project data between each election, so that I can interpolate values of valuables.

    Do you have any tips on how to do that? Your help would be much appreciated.

    Thanks in advance.

  • #2
    Seems you need command tsfill. But am example data generated by dataex (from SSC) would be helpful.

    Comment


    • #3
      Hi. Thank you. Here is an example:

      "Spain" "Aragonist Council" 2004 1.705
      "Spain" "Aragonist Council" 2008 1.025
      "Austria" "Austrian Communist Party" 2002 0
      "Austria" "Austrian Communist Party" 2008 0
      "Austria" "Austrian Freedom Party" 1990 2.8
      "Austria" "Austrian Freedom Party" 1994 1.011
      "Austria" "Austrian Freedom Party" 1999 .841

      So for example I need observations for "Austrian Freedom Party" in 1991, 1992, 1993 and so forth. So I can interpolate the values between 2.8 and 1.011

      Comment


      • #4
        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input str7 country str24 party int year float var
        "Spain"   "Aragonist Council"        2004 1.705
        "Spain"   "Aragonist Council"        2008 1.025
        "Austria" "Austrian Communist Party" 2002     0
        "Austria" "Austrian Communist Party" 2008     0
        "Austria" "Austrian Freedom Party"   1990   2.8
        "Austria" "Austrian Freedom Party"   1994 1.011
        "Austria" "Austrian Freedom Party"   1999  .841
        end
        
        egen id = group(country party)
        xtset id year
        tsfill
        bysort id (year): replace country = country[_n-1] if mi(country)
        bysort id (year): replace party = party[_n-1] if mi(party)
        drop id
        Data look like

        Code:
        . list, clean noo
        
            country                      party   year     var  
            Austria   Austrian Communist Party   2002       0  
            Austria   Austrian Communist Party   2003       .  
            Austria   Austrian Communist Party   2004       .  
            Austria   Austrian Communist Party   2005       .  
            Austria   Austrian Communist Party   2006       .  
            Austria   Austrian Communist Party   2007       .  
            Austria   Austrian Communist Party   2008       0  
            Austria     Austrian Freedom Party   1990     2.8  
            Austria     Austrian Freedom Party   1991       .  
            Austria     Austrian Freedom Party   1992       .  
            Austria     Austrian Freedom Party   1993       .  
            Austria     Austrian Freedom Party   1994   1.011  
            Austria     Austrian Freedom Party   1995       .  
            Austria     Austrian Freedom Party   1996       .  
            Austria     Austrian Freedom Party   1997       .  
            Austria     Austrian Freedom Party   1998       .  
            Austria     Austrian Freedom Party   1999    .841  
              Spain          Aragonist Council   2004   1.705  
              Spain          Aragonist Council   2005       .  
              Spain          Aragonist Council   2006       .  
              Spain          Aragonist Council   2007       .  
              Spain          Aragonist Council   2008   1.025

        Comment


        • #5
          Thank you so much, it worked perfectly!

          Comment

          Working...
          X