I am exporting regression tables using esttad with additional lines of stored values (which I store using estadd local as shown below). My data is panel of district level variables. How can I create a local that counts the number of distinct districts included in each regression?
Please find below the codes I have been using as well as the sample dataset.
Code:
qui eststo: reghdfe y x1, absorb(district year province#year) vce(cluster district) su y if e(sample), mean loc mymean: di %8.2f r(mean) estadd loc mD `mymean', replace estadd loc districtfe "YES", replace estadd loc yearfe "YES", replace estadd loc provinceyearfe "YES", replace estadd loc controls "NO", replace esttab using "$tables\outputfile.tex", se r2 label compress replace obslast depvars nocons /// keep(x) legend star(* 0.10 ** 0.05 *** 0.01) title("xxxs\label{tab1}") /// s(N mD controls districtfe yearfe provinceyearfe r2, labels("N" "DV Mean" "Controls" "District FE" "Year FE" "Province-Year FE" "R$^2$")) end
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float year double(district x1) float x2 2017 10115 48576 10.79293 2016 10115 43770 10.815013 2015 10115 41768.5 10.758085 2014 10115 40440 10.835257 2013 10115 42452.5 10.84151 2012 10115 44574.5 10.911667 2011 10115 39676 11.004084 2010 10115 31842 10.959435 2009 10115 31312 10.89785 2008 10115 26465 10.878846 2007 10115 22618 10.935728 2006 10115 18904 10.812347 2005 10115 16661.5 10.809118 2004 10115 13500.5 10.735826 2003 10115 10517.5 10.508248 2002 10115 10627 10.447365 2001 10115 6838.5 9.866043 2000 10115 4900 9.621317 2017 10311 61813 11.096008 2016 10311 48625.5 11.079721 2015 10311 37815.5 10.957888 2014 10311 32250 11.23849 2013 10311 33426 10.378188 2012 10311 34349 10.438468 2011 10311 35095.5 10.45002 2010 10311 32806.5 10.079932 2009 10311 32279 9.947844 2008 10311 28781.5 10.185665 2007 10311 21234 9.931454 2006 10311 15583.5 9.760022 2005 10311 12846.5 9.747766 2004 10311 11463 9.614722 2003 10311 8987.5 9.846739 2002 10311 7776.5 9.959849 2001 10311 6775 9.99496 2000 10311 5757.5 10.296524 2017 10313 112668.5 11.144252 2016 10313 95427.5 10.954016 2015 10313 79615 11.08856 2014 10313 73342.5 10.964838 2013 10313 73856.5 10.60652 2012 10313 64961.5 10.615115 2011 10313 61735 10.558088 2010 10313 53093.5 10.42195 2009 10313 55702 10.306606 2008 10313 64201 10.483128 2007 10313 47188.5 10.229994 2006 10313 36686 9.971215 2005 10313 31178 9.89325 2004 10313 27739.5 9.813892 2003 10313 22792.5 9.709494 2002 10313 17761 9.577569 2001 10313 20133.5 9.581846 2000 10313 13951 9.311994 2017 10511 25332.5 10.485425 2016 10511 25148.5 10.67426 2015 10511 20135.5 10.293143 2014 10511 17865.5 10.303815 2013 10511 17418 10.039917 2012 10511 16789 10.041409 2011 10511 17177 10.004248 2010 10511 11455.5 9.51729 2009 10511 9417 9.434856 2008 10511 8410 9.3116665 2007 10511 4460 9.78344 2006 10511 3907 9.567475 2005 10511 3252.5 9.332502 2004 10511 2632.5 9.066351 2003 10511 1958 8.596397 2002 10511 1850.5 8.336612 2001 10511 1821 8.193471 2000 10511 1471.5 7.489792 2017 10515 10937 9.57191 2016 10515 10664 9.560899 2015 10515 9949.5 9.460496 2014 10515 8403.5 9.507476 2013 10515 8413.5 9.30918 2012 10515 8810 9.36443 2011 10515 9858 9.356923 2010 10515 6615.5 9.749888 2009 10515 5279 9.0668125 2008 10515 5224.5 9.306926 2007 10515 4465 9.582626 2006 10515 2990.5 9.108054 2005 10515 2520 8.847734 2004 10515 2080.5 8.88162 2003 10515 1688 9.225299 2002 10515 1454.5 8.700666 2001 10515 1180.5 8.328477 2000 10515 1054 8.524872 2017 10517 26045 9.695479 2016 10517 25148 9.818636 2015 10517 21828.5 9.608504 2014 10517 22442.5 9.5386 2013 10517 23993 9.438197 2012 10517 24766 9.768464 2011 10517 25376 9.609882 2010 10517 20834.5 9.421533 2009 10517 20022 9.211345 2008 10517 17199.5 9.941608 end
Thank you,
Marina
0 Response to Storing and displaying the number of districts in the esttab regression table
Post a Comment