/* Purpose: assign the latest industry classification to all years */ clear all if "`1'"==""{ global CMF_pipeline "../.." } global strings "${CMF_pipeline}/2_string_cleaning/crosswalks" global industry "${CMF_pipeline}/5_industry_assignment" global interm "${industry}/intermediate_files" global county_assigned "${CMF_pipeline}/4_county_assignment/output" global output "${industry}/output" // -------- Assign industries to reshaped data (1850–1870) -------- foreach y in 1850 1860 1870 { use "${county_assigned}/`y'_county_fips_assigned.dta", clear cap drop ind_detailed ind_broadest ind_leontief ind_granular //var kept in prev data. cap drop _merge do "${industry}/code/industry_raw_clean" //generate `industry' cap drop _m merge m:1 industry using "${industry}/intermediate_files/industry_to_merge.dta", nogen keep(1 3) compress sort file_name firm_number do "${industry}/code/infer_industry_classification.do" save "${output}/`y'_industry_assigned.dta", replace } // -------- General 1880 schedule -------- use "${county_assigned}/1880_general_schedule_county_fips_assigned.dta", clear cap drop industry ind_detailed ind_broadest ind_leontief ind_granular cap drop file_name6 do "${industry}/code/industry_raw_clean" //generate `industry' merge m:1 industry using "$industry/intermediate_files/industry_to_merge.dta", nogen keep(1 3) compress missings dropvars, force do "${industry}/code/infer_industry_classification.do" save "${output}/1880_general_schedule_industry_assigned.dta", replace // -------- Special schedules (SS1–SS12, 1880) -------- // Each block loads county-assigned data, drops old classifications, // creates/assigns industry labels, merges with crosswalks, then saves output. use "${county_assigned}/1880_SS1_county_fips_assigned.dta", clear cap drop file_name6 cap drop ind_detailed ind_broadest ind_leontief ind_granular gen industry_recorded = "agriculture implements" gen ind_detailed = "agricultural implements" merge m:1 ind_detailed using "$interm/new_industry_crosswalk.dta" drop if _merge==2 drop _merge save "${output}/1880_SS1_industry_assigned.dta", replace use "${county_assigned}/1880_SS2_county_fips_assigned.dta", clear cap drop file_name6 cap drop ind_detailed ind_broadest ind_leontief ind_granular gen industry_recorded = "paper" gen ind_detailed = "paper" merge m:1 ind_detailed using "$interm/new_industry_crosswalk.dta" drop if _merge==2 drop _merge save "${output}/1880_SS2_industry_assigned.dta", replace use "${county_assigned}/1880_SS3_county_fips_assigned.dta", clear cap drop file_name6 cap drop ind_detailed ind_broadest ind_leontief ind_granular gen industry_recorded = "boots and shoes" gen ind_detailed = "boots and shoes" merge m:1 ind_detailed using "$interm/new_industry_crosswalk.dta" drop if _merge==2 drop _merge save "${output}/1880_SS3_industry_assigned.dta", replace use "${county_assigned}/1880_SS4_county_fips_assigned.dta", clear cap drop file_name6 cap drop ind_detailed ind_broadest ind_leontief ind_granular gen industry_recorded = "leather (tanned and curried)" gen ind_detailed1 = "leather, tanned" gen ind_detailed2 = "leather, curried" forvalues i = 1/2 { rename ind_detailed`i' ind_detailed merge m:1 ind_detailed using "$interm/new_industry_crosswalk.dta" rename ind_leontief ind_leontief`i' rename ind_granular ind_granular`i' rename ind_broadest ind_broadest`i' rename ind_detailed ind_detailed`i' drop if _merge==2 drop _merge } save "${output}/1880_SS4_industry_assigned.dta", replace use "${county_assigned}/1880_SS5_county_fips_assigned.dta", clear cap drop ind_detailed ind_broadest ind_leontief ind_granular cap drop file_name6 gen industry_recorded = "lumber mills and saw mills" gen ind_detailed = "lumber, sawed" merge m:1 ind_detailed using "$interm/new_industry_crosswalk.dta" drop if _merge==2 drop _merge save "${output}/1880_SS5_industry_assigned.dta", replace use "${county_assigned}/1880_SS6_county_fips_assigned.dta", clear cap drop file_name6 cap drop ind_detailed ind_broadest ind_leontief ind_granular gen industry_recorded = "brick yards and tile works" gen ind_detailed1 = "brick" gen ind_detailed2 = "brick, stone, and tile, n.s." forvalues i = 1/2 { rename ind_detailed`i' ind_detailed merge m:1 ind_detailed using "$interm/new_industry_crosswalk.dta" rename ind_leontief ind_leontief`i' rename ind_granular ind_granular`i' rename ind_broadest ind_broadest`i' rename ind_detailed ind_detailed`i' drop if _merge==2 drop _merge } save "${output}/1880_SS6_industry_assigned.dta", replace use "${county_assigned}/1880_SS7_county_fips_assigned.dta", clear cap drop file_name6 cap drop ind_detailed ind_broadest ind_leontief ind_granular gen industry_recorded = "flour and grist mills" gen ind_detailed = "flour and grist mills" merge m:1 ind_detailed using "$interm/new_industry_crosswalk.dta" drop if _merge==2 drop _merge save "${output}/1880_SS7_industry_assigned.dta", replace use "${county_assigned}/1880_SS8_county_fips_assigned.dta", clear cap drop file_name6 cap drop ind_detailed ind_broadest ind_leontief ind_granular gen industry_recorded = "cheese, butter and condensed milk factory" gen ind_detailed = "butter and cheese" merge m:1 ind_detailed using "$interm/new_industry_crosswalk.dta" drop if _merge==2 drop _merge save "${output}/1880_SS8_industry_assigned.dta", replace use "${county_assigned}/1880_SS9_county_fips_assigned.dta", clear cap drop file_name6 cap drop ind_detailed ind_broadest ind_leontief ind_granular gen industry_recorded = "slaughtering and meat-packing" gen ind_detailed = "slaughter and meat packing" merge m:1 ind_detailed using "$interm/new_industry_crosswalk.dta" drop if _merge==2 drop _merge save "${output}/1880_SS9_industry_assigned.dta", replace use "${county_assigned}/1880_SS10_county_fips_assigned.dta", clear cap drop file_name6 cap drop ind_detailed ind_broadest ind_leontief ind_granular gen industry_recorded = "salt works" gen ind_detailed = "salt" merge m:1 ind_detailed using "$interm/new_industry_crosswalk.dta" drop if _merge==2 drop _merge save "${output}/1880_SS10_industry_assigned.dta", replace use "${county_assigned}/1880_SS11_county_fips_assigned.dta", clear gen industry_recorded = "small coal mines" cap drop ind_detailed ind_broadest ind_leontief ind_granular gen ind_detailed = "mining, coal" merge m:1 ind_detailed using "$interm/new_industry_crosswalk.dta" drop if _merge==2 drop _merge save "${output}/1880_SS11_industry_assigned.dta", replace use "${county_assigned}/1880_SS12_county_fips_assigned.dta", clear gen industry_recorded = "quarries" cap drop ind_detailed ind_broadest ind_leontief ind_granular gen ind_detailed = "quarrying" merge m:1 ind_detailed using "$interm/new_industry_crosswalk.dta" drop if _merge==2 drop _merge save "${output}/1880_SS12_industry_assigned.dta", replace