/* This do file prepares the material kind attribute and unit variables from 1880 so that they are similar to the rest of the years */ if "`1'"==""{ global CMF_pipeline "../.." } global input "${CMF_pipeline}/5_industry_assignment/output" global interm "${CMF_pipeline}/7_standardize_1880/interm" forvalues schedule=1/12{ *Keep what is necessary and reshape use "${input}/1880_SS`schedule'_industry_assigned.dta", clear if `schedule'==4{ rename (tanning_mat_hemlock_bark tanning_mat_oak_bark tanning_mat_hides tanning_mat_skins currying_mat_leather currying_mat_skins currying_mat_oil) (mat_tanning_hemlock_bark mat_tanning_oak_bark mat_tanning_hides tanning_mat_tanning_skins mat_currying_leather mat_currying_skins mat_currying_oil) } if `schedule'==7{ drop mat_value_grain mat_value_wheat rename mat_other_grain mat_grain } if `schedule'==8{ rename milk_used mat_milk } if `schedule'==9{ drop mat_beeves_weight mat_beeves_value mat_sheep_weight mat_sheep_value mat_hogs_weight mat_hogs_value } if `schedule'==10{ rename (boiling_mat_coal1 boiling_mat_wood1) (mat_coal mat_wood) } if `schedule'==11{ continue //there is no material information recorded for schedule 11 } if `schedule'==12{ replace mat_coal=mat_coal_tons if mat_coal=="" & mat_wood=="" replace mat_wood=mat_wood_cords if mat_coal=="" & mat_wood=="" drop mat_coal_tons mat_wood_cords } keep file_name firm_number mat_* *drop mat_value_other reshape long mat_, i(file_name firm_number) j(material) string destring(mat_), replace force drop if regexm(material, "total")==1 | (regexm(material, "other")==1 & material!="other_wood" & material!="other_leather" & material!="other_grain") if `schedule'!=1{ drop if mat_==. } gsort file_name firm_number - mat_ bysort file_name firm_number: gen rank=_n *Rename variables to be in line with the rest of the CMF rename (material mat_) (material_kind material_qty) *Deal with things listed in value terms replace material_qty=. if regexm(material_kind,"value")==1 *remove underscore and other things, aligning it with the rest of the CMF replace material_kind = subinstr(material_kind,"_"," ",.) local remove value tanning currying foreach y in `remove'{ replace material_kind = subinstr(material_kind,"`y'","",.) if material_kind!="tanning skins" & material_kind!="currying skins" } replace material_kind = trim(material_kind) *get all misc into one "material" replace material_kind = "misc" if regexm(material_kind,"misc")==1 *Initialize units and attributes gen material_kind_attr="" gen material_standardized_unit="" levelsof(material_kind), local(material) foreach x in `material'{ global attr "" global unit "" if "`x'"=="rags"{ global attr "" global unit "tons" } else if "`x'"=="old paper"{ global attr "" global unit "tons" } else if "`x'"=="cotton waste"{ global attr "" global unit "tons" } else if "`x'"=="manilla stock"{ global attr "" global unit "tons" } else if "`x'"=="straw"{ global attr "" global unit "tons" } else if "`x'"=="corn stock"{ global attr "" global unit "tons" } else if "`x'"=="esparto grass"{ global attr "" global unit "tons" } else if "`x'"=="poplar wood"{ global attr "" global unit "cords" } else if "`x'"=="other wood"{ global attr "" global unit "cords" } else if "`x'"=="sole leather"{ global attr "sole" global unit "sides" } else if "`x'"=="upper leather"{ global attr "upper" global unit "sides" } else if "`x'"=="other leather"{ global attr "other" global unit "pounds" } else if "`x'"=="hemlock bark"{ global attr "" global unit "tons" } else if "`x'"=="oak bark"{ global attr "" global unit "tons" } else if "`x'"=="tanning skins"{ global attr "tanning" global unit "" } else if "`x'"=="currying skins"{ global attr "currying" global unit "" } else if "`x'"=="leather"{ global attr "" global unit "sides" } else if "`x'"=="oil"{ global attr "" global unit "gallons" } else if "`x'"=="wood"{ global attr "" global unit "cords" } else if "`x'"=="grain"{ global attr "" global unit "cords" } else if "`x'"=="wheat"{ global attr "" global unit "cords" } else if "`x'"=="milk"{ global attr "" global unit "pounds" } else if "`x'"=="coal"{ global attr "" global unit "tons" } replace material_kind_attr = "$attr" if material_kind == "`x'" replace material_standardized_unit = "$unit" if material_kind == "`x'" } if `schedule'==3{ replace material_kind="leather" if inlist(material_kind,"sole leather","upper leather","other_leather") } if `schedule'==4{ replace material_kind = "skins" if inlist(material_kind, "tanning skins","currying skins") } reshape wide material*, i(file_name firm_number) j(rank) save "${interm}/materials_1880_SS`schedule'.dta", replace }