I am working on a dataset of firms located in US counties for the years 2000-2018 although not all firms have observations for each year. At some point, in each county there is an election which I have marked as a "treated" dummy taking value 1 for that specific county-year observation and 0 otherwise. Many of these counties are neighboring each other. I want to create another dummy called "neighbor" for example taking value 1 for 5 neighboring counties of the previously mentioned "treated" ones for the year of the election and +1 +2 years. For this I have another file called something like "C\Desktop\neighboring counties" which links each US county to 5 neighbor ones. I report a small extract of each file with dataex. Each county is identified by a code (1073, 1089 and so on). I am using Stata 16.1 by the way. Any help would be much appreciated!
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str10 firm_id double Year long county float treated "098570104" 2000 1073 0 "098570104" 2001 1073 0 "428567101" 2001 1073 0 "098570104" 2002 1073 0 "428567101" 2002 1073 0 "428567101" 2003 1073 0 "098570104" 2004 1073 0 "428567101" 2004 1073 0 "098570104" 2005 1073 1 "428567101" 2005 1073 1 "098570104" 2006 1073 0 "428567101" 2006 1073 0 "098570104" 2007 1073 0 "428567101" 2007 1073 0 "098570104" 2008 1073 0 "428567101" 2008 1073 0 "098570104" 2009 1073 1 "428567101" 2009 1073 1 "098570104" 2010 1073 0 "428567101" 2010 1073 0 "098570104" 2011 1073 0 "428567101" 2011 1073 0 "098570104" 2012 1073 0 "428567101" 2012 1073 0 "098570104" 2013 1073 0 "428567101" 2013 1073 0 "098570104" 2014 1073 0 "428567101" 2014 1073 0 "428567101" 2015 1073 0 "428567101" 2016 1073 0 "428567101" 2017 1073 0 "00738A106" 2000 1089 0 "00738A106" 2001 1089 0 "00738A106" 2002 1089 0 "00738A106" 2003 1089 0 "00738A106" 2004 1089 0 "00738A106" 2005 1089 0 "00738A106" 2006 1089 0 "00738A106" 2007 1089 0 "00738A106" 2008 1089 0 "053893103" 2008 1089 0 "00738A106" 2009 1089 0 "00738A106" 2010 1089 0 "00738A106" 2011 1089 0 "00738A106" 2012 1089 0 "00738A106" 2013 1089 0 "00738A106" 2014 1089 0 "00738A106" 2015 1089 0 "00738A106" 2016 1089 0 "00738A106" 2017 1089 0 end
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long(county neighbor) 1001 1021 1001 1047 1001 1051 1001 1085 1001 1101 1003 1025 1003 1053 1003 1097 1003 1099 1003 1129 1003 12033 1005 1011 1005 1045 1005 1067 1005 1109 1005 1113 1005 13061 1005 13239 1005 13259 1007 1021 1007 1065 1007 1073 1007 1105 1007 1117 1007 1125 1009 1043 1009 1055 1009 1073 1009 1095 1009 1115 end
0 Response to Identify neighboring counties for treatment year and subsequent 2 years
Post a Comment