use "$dir_root/Data/_temp/us_1910_directory", clear

gen num_total=1

* by frequency
gen num_daily=(frequency_std=="d")
gen num_weekly=(inlist(frequency_std,"w","tw","thrice"))
gen num_other=(num_daily==0 & num_weekly==0)


* by type
gen num_democrat=(affiliation_std=="democrat")
gen num_republican=(affiliation_std=="republican")
gen num_independent=(affiliation_std=="independent")
gen num_trade=(inlist(affiliation_std,"trade","agricultural"))
gen num_religious=(affiliation_std=="religious")
gen num_type_other=(inlist(affiliation_std,"other","college","labor","local","missing"))

*By cost
destring sub, replace ignore("?")

gen num_cost_0_1=(sub<1)
gen num_cost_1=(sub==1)
gen num_cost_1_2=(sub>1 & sub<2)
gen num_cost_2=(sub==2)
gen num_cost_2up=(sub>2 & sub!=.)

* Specialty papers


gen num_black=(black_paper==1)
gen num_foreign=(foreign_language_paper==1)


collapse (sum) num_*

*Circulation
label var num_total "Total"
label var num_daily "Daily (4+ times per week)"
label var num_weekly "Weekly (1-4 times per week)"
label var num_other "Other/unknown"

*Type
label var num_democrat "Democrat"
label var num_republican "Republican"
label var num_independent "Independent"
label var num_trade "Trade/bus."
label var num_religious "Religious"
label var num_type_other "Other/unknown"

*Cost
label var num_cost_0_1 "Below one"
label var num_cost_1 "One dollar"
label var num_cost_1_2 "One to two"
label var num_cost_2 "Two dollars"
label var num_cost_2up "Above two"

*Other
label var num_black "Black" 
label var num_foreign "Foreign lang."

cd "$dir_root/Results" 

sutex num_daily num_weekly num_other num_total num_republican num_democrat num_independent num_trade num_religious num_type_other num_cost_0_1 num_cost_1 num_cost_1_2 num_cost_2 num_cost_2up num_black num_foreign, labels file(T4_US_Directory_stats) replace
