Announcement

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

  • Joining missing years

    Dear all,

    I have my panel data below. However, I don't have years for the year 2001. This is same for each unit. However, I want to add the year 2001. I really don't know how to add this missing year. I am doing this for merging this dataset with other variables. Thank you so much,

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str3 ccode int year str30 country str18 concor
    "ABW" 2000 "Aruba"       "#N/A"              
    "ABW" 2002 "Aruba"       "#N/A"              
    "ABW" 2003 "Aruba"       "#N/A"              
    "ABW" 2004 "Aruba"       "1.184471964836121" 
    "ABW" 2005 "Aruba"       "1.278152942657471" 
    "ABW" 2006 "Aruba"       "1.259531140327454" 
    "ABW" 2007 "Aruba"       "1.269964575767517" 
    "ABW" 2008 "Aruba"       "1.288655161857605" 
    "ABW" 2009 "Aruba"       "1.116361260414124" 
    "ABW" 2010 "Aruba"       "1.127541184425354" 
    "ABW" 2011 "Aruba"       "1.110036373138428" 
    "ABW" 2012 "Aruba"       "1.102628469467163" 
    "ABW" 2013 "Aruba"       "1.126579642295837" 
    "ABW" 2014 "Aruba"       "1.019108176231384" 
    "ABW" 2015 "Aruba"       "1.297560214996338" 
    "ABW" 2016 "Aruba"       "1.285870671272278" 
    "ABW" 2017 "Aruba"       "1.294589042663574" 
    "ABW" 2018 "Aruba"       "1.25244665145874"  
    "ABW" 2019 "Aruba"       "1.217545986175537" 
    "ABW" 2020 "Aruba"       "1.235405087471008" 
    "ADO" 2000 "Andorra"     "1.359711885452271" 
    "ADO" 2002 "Andorra"     "1.349896430969238" 
    "ADO" 2003 "Andorra"     "1.376689910888672" 
    "ADO" 2004 "Andorra"     "1.137412428855896" 
    "ADO" 2005 "Andorra"     "1.278152942657471" 
    "ADO" 2006 "Andorra"     "1.259531140327454" 
    "ADO" 2007 "Andorra"     "1.269964575767517" 
    "ADO" 2008 "Andorra"     "1.288655161857605" 
    "ADO" 2009 "Andorra"     "1.325579285621643" 
    "ADO" 2010 "Andorra"     "1.308456063270569" 
    "ADO" 2011 "Andorra"     "1.279335737228394" 
    "ADO" 2012 "Andorra"     "1.267988801002502" 
    "ADO" 2013 "Andorra"     "1.260758519172668" 
    "ADO" 2014 "Andorra"     "1.225432157516479" 
    "ADO" 2015 "Andorra"     "1.218931436538696" 
    "ADO" 2016 "Andorra"     "1.228803873062134" 
    "ADO" 2017 "Andorra"     "1.245125532150269" 
    "ADO" 2018 "Andorra"     "1.239041328430176" 
    "ADO" 2019 "Andorra"     "1.234695911407471" 
    "ADO" 2020 "Andorra"     "1.314373970031738" 
    "AFG" 2000 "Afghanistan" "-1.295379877090454"
    "AFG" 2002 "Afghanistan" "-1.263365983963013"
    "AFG" 2003 "Afghanistan" "-1.351041913032532"
    "AFG" 2004 "Afghanistan" "-1.345281362533569"
    "AFG" 2005 "Afghanistan" "-1.443609237670898"
    "AFG" 2006 "Afghanistan" "-1.432889819145203"
    "AFG" 2007 "Afghanistan" "-1.587331414222717"
    "AFG" 2008 "Afghanistan" "-1.638286590576172"
    "AFG" 2009 "Afghanistan" "-1.534795999526978"
    "AFG" 2010 "Afghanistan" "-1.636176943778992"
    "AFG" 2011 "Afghanistan" "-1.579173922538757"
    "AFG" 2012 "Afghanistan" "-1.41974139213562" 
    "AFG" 2013 "Afghanistan" "-1.436510324478149"
    "AFG" 2014 "Afghanistan" "-1.354828834533691"
    "AFG" 2015 "Afghanistan" "-1.342215895652771"
    "AFG" 2016 "Afghanistan" "-1.526171565055847"
    "AFG" 2017 "Afghanistan" "-1.515625596046448"
    "AFG" 2018 "Afghanistan" "-1.487624168395996"
    "AFG" 2019 "Afghanistan" "-1.40073299407959" 
    "AFG" 2020 "Afghanistan" "-1.475404500961304"
    "AGO" 2000 "Angola"      "-1.522685050964355"
    "AGO" 2002 "Angola"      "-1.183629155158997"
    "AGO" 2003 "Angola"      "-1.32066547870636" 
    "AGO" 2004 "Angola"      "-1.31355881690979" 
    "AGO" 2005 "Angola"      "-1.296138882637024"
    "AGO" 2006 "Angola"      "-1.220061182975769"
    "AGO" 2007 "Angola"      "-1.289693236351013"
    "AGO" 2008 "Angola"      "-1.284620642662048"
    "AGO" 2009 "Angola"      "-1.404654502868652"
    "AGO" 2010 "Angola"      "-1.326095223426819"
    "AGO" 2011 "Angola"      "-1.344277262687683"
    "AGO" 2012 "Angola"      "-1.268470168113708"
    "AGO" 2013 "Angola"      "-1.309463381767273"
    "AGO" 2014 "Angola"      "-1.443943738937378"
    "AGO" 2015 "Angola"      "-1.395013570785522"
    "AGO" 2016 "Angola"      "-1.439528226852417"
    "AGO" 2017 "Angola"      "-1.410952806472778"
    "AGO" 2018 "Angola"      "-1.13919198513031" 
    "AGO" 2019 "Angola"      "-1.054450631141663"
    "AGO" 2020 "Angola"      "-.9270931482315063"
    "AIA" 2000 "Anguilla"    "#N/A"              
    "AIA" 2002 "Anguilla"    "#N/A"              
    "AIA" 2003 "Anguilla"    "#N/A"              
    "AIA" 2004 "Anguilla"    ".8550555109977722" 
    "AIA" 2005 "Anguilla"    "1.278152942657471" 
    "AIA" 2006 "Anguilla"    "1.259531140327454" 
    "AIA" 2007 "Anguilla"    "1.269964575767517" 
    "AIA" 2008 "Anguilla"    "1.288655161857605" 
    "AIA" 2009 "Anguilla"    "1.325579285621643" 
    "AIA" 2010 "Anguilla"    "1.308456063270569" 
    "AIA" 2011 "Anguilla"    "1.279335737228394" 
    "AIA" 2012 "Anguilla"    "1.267988801002502" 
    "AIA" 2013 "Anguilla"    "1.260758519172668" 
    "AIA" 2014 "Anguilla"    "1.225432157516479" 
    "AIA" 2015 "Anguilla"    "1.218931436538696" 
    "AIA" 2016 "Anguilla"    "1.228803873062134" 
    "AIA" 2017 "Anguilla"    "1.245125532150269" 
    "AIA" 2018 "Anguilla"    "1.239041328430176" 
    "AIA" 2019 "Anguilla"    "1.234695911407471" 
    "AIA" 2020 "Anguilla"    ".6787987947463989" 
    end
    copy up to and including the previous line -- ---------------

    Listed 100 out of 4280 observations
    Use the count() option to list more

  • #2
    If you add an extra year, it won't matter. You'll have missing data either way, and when you merge it, it won't make a difference.

    Comment


    • #3
      How can i merge without the year 2001? Stata will throw an error because my panel and other variables have 2001.

      Also, I will use concor as a control variable. So, in some models, concor will be included and I will have one missing year. But this will not be the case for other models. Jared Greathouse

      Comment


      • #4
        Trust me, believe you me, as someone who regularly uses the merge command, Stata will definitely not throw an error if your years and so on aren't the same. They'll just come back as missing/not matched. I would simulate this were I at my computer, but I don't need to.

        If I have a dataset with 1 unit from 1900-1910, and another dataset with unit 1 from 1900-1911, when I do
        Code:
        mer 1:1 id year using data2
        11 observations will be matched and 1 will not be. Or, the variable _merge would have only one value equal to 3, "using dataset only" because 1911 was only in dataset 2, not dataset one.

        Comment


        • #5
          Jared Greathouse is quite correct. merge will recognise the absent data (a better term here than "missing") as just unmatched. It is not necessary and indeed a waste of time and effort to insert observations to show missings.

          Comment


          • #6
            Dear Nick and Jared,

            Thank you so much for the information, I got it now.

            Best

            Comment

            Working...
            X