global program "EEREV-D-21-00004_TableC1"

cap log close
cap log using "$log\log_$program$today", replace

**** REPLICATION OF TABLE C1 ****

clear all
set mem 2g
set more off

/*	
	OUTLINE
	1. CANTON REGRESSIONS
	2. TABLE FOR PAPER
*/

*********************************
***** 1. CANTON REGRESSIONS *****
*********************************

// Import Cantonal data

use $data\EEREV-D-21-00004_Data_Canton1936.dta, clear

// Controls vector

global rdd2 		"rdd_lat rdd_lon rdd_lat_2 rdd_lon_2 rdd_lat_lon"
global sigma 		"lelevation_mean lelevation_std $rdd2 water ldist_de"

// Regressions

foreach party in profe_agric_1907 profe_indus_1907 perc_fore_1936 perc_male_1936 perc_prot_1936 perc_jewi_1936 perc_fran_1936 perc_dial_1936{

	reg `party' alsace, cluster(ar_1936_enc)
	estimates store `party'_1
	qui sum `party' if e(sample)
	scalar mean_y=r(mean)
	estadd scalar mean_y

	ivreghdfe `party' alsace $sigma, cluster(ar_1936_enc) a(dialect_lux dialect_mos dialect_rhe dialect_pal dialect_als dialect_hau dialect_lor dialect_fra borderfe25) partial($sigma)
	estimates store `party'_2
	qui sum `party' if e(sample)
	scalar mean_y=r(mean)
	estadd scalar mean_y

	ivreghdfe `party' alsace $sigma if sample==1, robust a(dialect_lux dialect_mos dialect_rhe dialect_pal dialect_als dialect_hau dialect_lor dialect_fra borderfe25) partial($sigma)
	estimates store `party'_3
	qui sum `party' if e(sample)
	scalar mean_y=r(mean)
	estadd scalar mean_y
	
}

******************************
***** 2. TABLE FOR PAPER *****
******************************

// Unconditional 

estout profe_agric_1907_1 profe_indus_1907_1 perc_fore_1936_1 perc_male_1936_1 perc_prot_1936_1 perc_jewi_1936_1 perc_fran_1936_1 perc_dial_1936_1 ///
	using "$results\\$program.tex", replace style(tex) type label ///
	cells(b(star fmt(%9.3f)) se(par fmt(%9.3f)))  ///
	stats(mean_y N N_clust, lab("Mean dep. variable" "Observations" "Clusters") fmt(2 %9.0fc 0)) ///
	collabels(none) ///
	mlabels(, span none prefix(\multicolumn{@span}{c}{) suffix(})) ///
	msign(--) starlevels(* .1 ** .05 *** .01) ///
	keep(alsace) ///
	order(alsace) ///
	title(Estimation strategy: Pre-War comparability) ///
	prehead("" ///
	"\begin{table}[t!]" ///
	"\begin{center}" ///
	"\begin{threeparttable}" ///
	"\begin{scriptsize}" ///
	"\caption{@title\label{$program}}" ///
	"\begin{tabular*}{\columnwidth}{@{\extracolsep{\stretch{1}}}l*{@M}{c}@{}}" ///
	"\hline" "\hline" ///
	"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)}  &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} &\multicolumn{1}{c}{(5)} &\multicolumn{1}{c}{(6)} &\multicolumn{1}{c}{(7)}  &\multicolumn{1}{c}{(8)} \\" ///    
	"	&\multicolumn{2}{c}{Occupation 1907} &\multicolumn{2}{c}{Population 1936} &\multicolumn{2}{c}{Religion 1936} &\multicolumn{2}{c}{Language 1936}\\" ///
	"	&\multicolumn{2}{c}{\citep{rosse1938elsass}} &\multicolumn{2}{c}{\citep{maitre1958aspects}} &\multicolumn{2}{c}{\citep{maitre1958aspects}} &\multicolumn{2}{c}{\citep{maitre1958aspects}}\\" ///
	"\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7} \cmidrule(lr){8-9}" ///
	"\multicolumn{1}{l}{\textit{Dep. Variable}} &\multicolumn{1}{c}{Agriculture}  &\multicolumn{1}{c}{Industry}  	&\multicolumn{1}{c}{Foreign} &\multicolumn{1}{c}{Male}   &\multicolumn{1}{c}{Protestant} &\multicolumn{1}{c}{Jewish}   &\multicolumn{1}{c}{French}   &\multicolumn{1}{c}{Dialect}   \\" ///
	"\cmidrule(lr){2-9}" ///
	"& \multicolumn{8}{c}{Panel A: Unconditional differences}\\") ///
	posthead("\hline" ///
	"\\") ///
	prefoot("\\") ///
	postfoot("\\")

// Conditional

estout profe_agric_1907_2 profe_indus_1907_2 perc_fore_1936_2 perc_male_1936_2 perc_prot_1936_2 perc_jewi_1936_2 perc_fran_1936_2 perc_dial_1936_2 ///
	using "$results\\$program.tex", append style(tex) type label ///
	cells(b(star fmt(%9.3f)) se(par fmt(%9.3f)))  ///
	stats(mean_y N N_clust, lab("Mean dep. variable" "Observations" "Clusters") fmt(2 %9.0fc 0)) ///
	collabels(none) ///
	mlabels(, span none prefix(\multicolumn{@span}{c}{) suffix(})) ///
	msign(--) starlevels(* .1 ** .05 *** .01) ///
	keep(alsace) ///
	order(alsace) ///
	prehead("\cmidrule(lr){2-9}" ///
	"& \multicolumn{8}{c}{Panel B: Conditional on geography and dialect}\\") ///
	posthead("\hline" ///
	"\\") ///
	prefoot("\\") ///
	postfoot("\\")

// Conditional: Estimation sample

estout profe_agric_1907_3 profe_indus_1907_3 perc_fore_1936_3 perc_male_1936_3 perc_prot_1936_3 perc_jewi_1936_3 perc_fran_1936_3 perc_dial_1936_3 ///
	using "$results\\$program.tex", append style(tex) type label ///
	cells(b(star fmt(%9.3f)) se(par fmt(%9.3f)))  ///
	stats(mean_y N, lab("Mean dep. variable" "Observations") fmt(2 %9.0fc)) ///
	collabels(none) ///
	mlabels(, span none prefix(\multicolumn{@span}{c}{) suffix(})) ///
	msign(--) starlevels(* .1 ** .05 *** .01) ///
	keep(alsace) ///
	order(alsace) ///
	prehead("\cmidrule(lr){2-9}" ///
	"& \multicolumn{8}{c}{Panel C: Conditional on geography and dialect (estimation sample)}\\") ///
	posthead("\hline" ///
	"\\") ///
	prefoot("\\") ///
	postfoot("\hline" "\hline" ///
	"\end{tabular*}" /// 
	"\end{scriptsize}" ///
	"\begin{tablenotes}[normal,flushleft]" ///
	"\begin{scriptsize}" ///
	"\item \emph{Notes}:" /// 
	"Differences in pre-War occupation, population, religions, and language between Alsace and Moselle. " ///
	"The unit of observation is a 1936 canton. " ///
	"Panel A: Unconditional differences; " ///
	"Panel B: Differences conditional on geography and dialects; " ///
	"Panel C: Differences conditional on geography and dialects (estimation sample). " ///
	"Column (1): Share of the population occupied in agriculture in 1907; " ///
	"Column (2): Share of the population occupied in industry in 1907; " ///
	"Column (3): Share of foreign population in 1936; " ///
	"Column (4): Share of male population in 1936; " ///
	"Column (5): Share of population of protestant confession in 1936; " ///
	"Column (6): Share of population of jewish confession in 1936; " ///	
	"Column (7): Share of french-speaking population in 1936; " ///
	"Column (8): Share of dialect-speaking population in 1936; " ///
	"Geography and dialects controls included in Panels B and C: " ///
	"access to waterways (binary), elevation (log mean, log std.dev.), distance to Germany (log km), 25km border segment fixed-effects, " ///
	"historical dialect fixed effects, and a quadratic polynomial in latitude and longitude ($ x+y+x^2+y^2+xy $). " ///
	"Standard errors clustered at the arrondissement level in parentheses in Panels A and B; " ///
	"robust standard errors in Panel C. " ///
	"* significant at 10\%; ** at 5\%; *** at 1\%. " ///	
	"\end{scriptsize}" ///
	"\end{tablenotes}" ///
	"\end{threeparttable}" ///
	"\end{center}" ///
	"\end{table}") //

cap log close
