Dear Stata users,

I am working with a panel data set. I'm trying to see how government policies affect the number of firms and their employees in the county. Cities are located within counties. Each county may have different number of cities and some have no cities, only a county government. City and county government policies can affect the total number of firms in the county. My outcome variables (firms0 employees) are at the county level and represent the total number of firms and their employees in each county. My predictors (new_land new_tax new_bonds) are at the city and county level.

I am trying to find a way to fill in the outcome variable for cities based on the county-year. For example, we can see in the data sample below that there were 385 firms in Appling county in 2000. There are 3 cities in this county, I would like to replace the missing values for all three cities in Appling county with 385 in 2000, and 373 in 2001. For all cities in Atkinson county the number of firms would be 86 in 2000, and 97 in 2001. And so on with other cities. Is there a reliable way of doing this in Stata? Name uniquely identifies each city and county in this data set.

Thank you for your help in advance.


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str17 county str24 name int year str6 govtype float(new_land new_tax new_bonds) long(firms0 employees)
"Appling"  "Baxley city"        2000 "city"   2 3 0    .     .
"Appling"  "Surrency city"      2000 "city"   0 0 0    .     .
"Appling"  "Graham city"        2000 "city"   0 0 0    .     .
"Appling"  "Appling county"     2000 "county" 2 2 1  385  4693
"Appling"  "Appling county"     2001 "county" 2 1 0  373  4653
"Appling"  "Baxley city"        2001 "city"   0 0 0    .     .
"Appling"  "Surrency city"      2001 "city"   0 0 0    .     .
"Appling"  "Graham city"        2001 "city"   1 0 0    .     .
"Atkinson" "Atkinson county"    2000 "county" 1 2 1   86  1268
"Atkinson" "Pearson city"       2000 "city"   1 0 0    .     .
"Atkinson" "Willacoochee city"  2000 "city"   2 0 0    .     .
"Atkinson" "Willacoochee city"  2001 "city"   2 1 0    .     .
"Atkinson" "Atkinson county"    2001 "county" 0 0 0   97  1383
"Atkinson" "Pearson city"       2001 "city"   2 1 0    .     .
"Bacon"    "Alma city"          2000 "city"   1 1 1    .     .
"Bacon"    "Bacon county"       2000 "county" 2 2 1  201  2799
"Bacon"    "Alma city"          2001 "city"   2 2 0    .     .
"Bacon"    "Bacon county"       2001 "county" 2 2 1  216  2855
"Baker"    "Baker county"       2000 "county" 0 2 0   21   214
"Baker"    "Newton city"        2000 "city"   0 0 0    .     .
"Baker"    "Baker county"       2001 "county" 0 0 0   25   267
"Baker"    "Newton city"        2001 "city"   0 0 0    .     .
"Baldwin"  "Baldwin county"     2000 "county" 1 2 1  851 15271
"Baldwin"  "Milledgeville city" 2000 "city"   0 0 1    .     .
"Baldwin"  "Milledgeville city" 2001 "city"   0 0 0    .     .
"Baldwin"  "Baldwin county"     2001 "county" 1 0 1  847 14566

end