I have a cross-country panel dataset with multiple countries and firms over the sample period 1981-2019.
I want to drop countries which do not have at least three firms in each financial year. For example, for country A, there should be at least three firms (B,C,D) and all three firms should have data for all the years, from 1981-2019. Otherwise, I need to drop the countries.
Below is a small sample of my data.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str32 countryname double(companyid year tot_assets) "Albania" 3734764 2010 1502902 "Albania" 3734764 2011 1864689 "Albania" 3734764 2012 2337314 "Albania" 3734764 2013 2675742 "Albania" 3734764 2014 10989460 "Albania" 3734764 2015 10776339 "Albania" 3734764 2016 14808676 "Albania" 3734764 2017 13525039 "Albania" 3734764 2018 7653391 "Albania" 12761602 2010 90558535 "Albania" 12761602 2011 93623945 "Albania" 12761602 2012 97485381 "Albania" 12761602 2013 101379321 "Albania" 12761602 2014 101708499 "Albania" 12761602 2015 81461806 "Albania" 12761602 2016 81364754 "Albania" 12761602 2017 77784899 "Albania" 12761602 2018 0 "Albania" 21988056 2010 5117584 "Albania" 21988056 2011 6203623 "Albania" 21988056 2012 6286929 "Albania" 21988056 2013 6203736 "Albania" 21988056 2014 6262487 "Albania" 21988056 2015 6264344 "Albania" 21988056 2016 7531626 "Albania" 21988056 2017 8594377 "Albania" 21988056 2018 0 "Albania" 22866044 2010 277983651 "Albania" 22866044 2011 322854297 "Albania" 22866044 2012 318918623 "Albania" 22866044 2013 291796555 "Albania" 22866044 2014 276446521 "Albania" 22866044 2015 290457704 "Albania" 22866044 2016 270537453 "Albania" 22866044 2017 250454912 "Albania" 22866044 2018 0 "Albania" 26269860 2010 40610102 "Albania" 26269860 2011 39850575 "Albania" 26269860 2012 39979809 "Albania" 26269860 2013 40360109 "Albania" 26269860 2014 36804190 "Albania" 26269860 2015 34967025 "Albania" 26269860 2016 33233585 "Albania" 26269860 2017 34163812 "Albania" 26269860 2018 0 "Albania" 29571446 2010 120632012 "Albania" 29571446 2011 129033450 "Albania" 29571446 2012 129932085 "Albania" 29571446 2013 139237787 "Albania" 29571446 2014 616392174 "Albania" 29571446 2015 600014080 "Albania" 29571446 2016 302304744 "Albania" 29571446 2017 154246155 "Albania" 29571446 2018 0 "Albania" 33957004 2010 0 "Albania" 33957004 2011 56755352 "Albania" 33957004 2012 62098356 "Albania" 33957004 2013 69918648 "Albania" 33957004 2014 71527268 "Albania" 33957004 2015 73277802 "Albania" 33957004 2016 81221920 "Albania" 33957004 2017 81419103 "Albania" 33957004 2018 0 "Albania" 40275950 2010 71020392 "Albania" 40275950 2011 84217207 "Albania" 40275950 2012 91824641 "Albania" 40275950 2013 107467359 "Albania" 40275950 2014 370930389 "Albania" 40275950 2015 572771661 "Albania" 40275950 2016 165483106 "Albania" 40275950 2017 179581853 "Albania" 40275950 2018 0 "Albania" 43833537 2010 21343687 "Albania" 43833537 2011 23415942 "Albania" 43833537 2012 28078859 "Albania" 43833537 2013 32675593 "Albania" 43833537 2014 35824183 "Albania" 43833537 2015 38166191 "Albania" 43833537 2016 41615106 "Albania" 43833537 2017 46538628 "Albania" 43833537 2018 0 "Albania" 44456832 2010 8751527 "Albania" 44456832 2011 13716913 "Albania" 44456832 2012 17381927 "Albania" 44456832 2013 22498656 "Albania" 44456832 2014 26909454 "Albania" 44456832 2015 26087476 "Albania" 44456832 2016 26429322 "Albania" 44456832 2017 28016310 "Albania" 47018265 2010 364948000 "Albania" 47018265 2011 380793000 "Albania" 47018265 2012 390578000 "Albania" 47018265 2013 395942000 "Albania" 47018265 2014 862343000 "Albania" 47018265 2015 494552000 "Albania" 47018265 2016 524656000 "Albania" 47018265 2017 532852000 "Albania" 49209688 2010 7134700 "Albania" 49209688 2011 8673257 "Albania" 49209688 2012 8566644 end
0 Response to Drop countries which do not have at least three firms in each year
Post a Comment