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

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

**** REPLICATION OF TABLE B1 ****

clear all
set mem 2g
set more off

/*	
	OUTLINE
	1. INDEX DATA - INDIVIDUAL
	2. INDEX DATA - AGGREGATE
*/

**************************************
***** 1. INDEX DATA - INDIVIDUAL *****
**************************************

// Import data

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

// Full sample

estpost tabstat ///
	residinfo birthinfo drafted born_1908_1913 born_1914_1927 ///
	, s(N mean sd min max p5 p50 p95) columns(statistics)
	
matrix N=e(count)
matrix m=e(Mean)
matrix s=e(SD)
matrix i=e(Min)
matrix a=e(Max)
matrix x=e(p5)
matrix y=e(p50)
matrix z=e(p95)

matrix obs = N'
matrix mean=m'
matrix sd=s'
matrix min=i'
matrix max=a'
matrix p5=x'
matrix p50=y'
matrix p95=z'

matrix b1 = obs, mean, sd, min, p5, p50, p95, max
matrix list b1

// Labels

la var residinfo "\\ Residence info"
la var birthinfo "[0.3em] Birth info"
la var residbirthinfo "Residence and birth info"
la var drafted "[0.3em] Born year drafted"
la var born_1908_1913 "[0.3em] \multicolumn{1}{l}{Born 1908-1913}"
la var born_1914_1927 "[0.3em] \multicolumn{1}{l}{Born 1914-1927}"

// Table

estout matrix(b1, fmt(%9.0fc 2 2 0 0 0 0 0)) using ///
	"$results\\$program.tex", replace style(tex) type label ///
	unstack collabels(none) ///
	mlabels(, none) ///
	msign(--) ///
	title(Conscription proxy: Data description) ///
	prehead("\begin{table}[t!]" ///
	"\begin{center}" ///
	"\begin{threeparttable}" ///
	"\begin{scriptsize}" ///
	"\caption{@title}\label{$program}" ///
	"\label{$table}"  /// 
	"\begin{tabular*}{\columnwidth}{@{\extracolsep{\stretch{1}}}l*{8}{c}@{}}" ///
	"\hline" "\hline" ///
	"&\multicolumn{3}{c}{Statistics} &\multicolumn{5}{c}{Distribution}\\" ///
	"\cmidrule(lr){2-4} \cmidrule(lr){5-9}" ///
	"\textit{Variable}	&\multicolumn{1}{c}{Obs.} &\multicolumn{1}{c}{Mean}  &\multicolumn{1}{c}{Std.Dev.}  &\multicolumn{1}{c}{Min}  &\multicolumn{1}{c}{5th pctile}   &\multicolumn{1}{c}{Median}  &\multicolumn{1}{c}{95th pctile}   &\multicolumn{1}{c}{Max}\\") ///
	posthead("\hline") ///
	prefoot("") ///
	postfoot("")

*************************************
***** 2. INDEX DATA - AGGREGATE *****
*************************************

// Import data

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

drop if annee!=1969
drop if dep!=57 & dep!=67 & dep!=68

// Full sample

estpost tabstat ///
	indexinfo indexinfo0813 indexinfo1427 ///
	, s(N mean sd min max p5 p50 p95) columns(statistics) //
	
matrix N=e(count)
matrix m=e(Mean)
matrix s=e(SD)
matrix i=e(Min)
matrix a=e(Max)
matrix x=e(p5)
matrix y=e(p50)
matrix z=e(p95)

matrix obs = N'
matrix mean=m'
matrix sd=s'
matrix min=i'
matrix max=a'
matrix p5=x'
matrix p50=y'
matrix p95=z'

matrix b2 = obs, mean, sd, min, p5, p50, p95, max
matrix list b2

// Labels

la var indexinfo "\\ Declared missing (Binary)"
la var indexinfo0813	"[0.3em] \multicolumn{1}{l}{Born 1908-1913 (Binary)}"
la var indexinfo1427	"[0.3em] \multicolumn{1}{l}{Born 1914-1927 (Binary)}"

// Table

estout matrix(b2, fmt(%9.0fc 2 2 0 0 0 0 0)) using ///
	"$results\\$program.tex", append style(tex) type label ///
	unstack collabels(none) ///
	mlabels(, none) ///
	msign(--) ///
	prehead("") ///
	posthead("") ///
	prefoot("") ///
	postfoot("")

// Full sample

estpost tabstat ///
	m_all m_1908_1913 m_1914_1927 ///
	, s(N mean sd min max p5 p50 p95) columns(statistics) //
	
matrix N=e(count)
matrix m=e(Mean)
matrix s=e(SD)
matrix i=e(Min)
matrix a=e(Max)
matrix x=e(p5)
matrix y=e(p50)
matrix z=e(p95)

matrix obs = N'
matrix mean=m'
matrix sd=s'
matrix min=i'
matrix max=a'
matrix p5=x'
matrix p50=y'
matrix p95=z'

matrix b3 = obs, mean, sd, min, p5, p50, p95, max
matrix list b3

// Table
	
la var m_all 		"\\ Declared missing (\#)"
la var m_1908_1913	"[0.3em] \multicolumn{1}{l}{Born 1908-1913 (\#)}"
la var m_1914_1927	"[0.3em] \multicolumn{1}{l}{Born 1914-1927 (\#)}"

estout matrix(b3, fmt(%9.0fc 1 1 %9.0fc %9.0fc %9.0fc %9.0fc %9.0fc)) using ///
	"$results\\$program.tex", append style(tex) type label ///
	unstack collabels(none) ///
	mlabels(, none) ///
	msign(--) ///
	prehead("") ///
	posthead("") ///
	prefoot("") ///
	postfoot("")

// Full sample

estpost tabstat ///
	perc_m_full perc_m_1908_1913 perc_m_1914_1927 ///
	, s(N mean sd min max p5 p50 p95) columns(statistics) //nototal // listwiseby(place) 
	
matrix N=e(count)
matrix m=e(Mean)
matrix s=e(SD)
matrix i=e(Min)
matrix a=e(Max)
matrix x=e(p5)
matrix y=e(p50)
matrix z=e(p95)

matrix obs = N'
matrix mean=m'
matrix sd=s'
matrix min=i'
matrix max=a'
matrix p5=x'
matrix p50=y'
matrix p95=z'

matrix b4 = obs, mean, sd, min, p5, p50, p95, max
matrix list b4

// Labels
	
la var perc_m_full		"\\ Declared missing (\%)"
la var perc_m_1908_1913	"[0.3em] \multicolumn{1}{l}{Born 1908-1913 (\%)}"
la var perc_m_1914_1927	"[0.3em] \multicolumn{1}{l}{Born 1914-1927 (\%)}"

// Table

estout matrix(b4, fmt(%9.0fc 1 1 0 0 1 1 1)) using ///
	"$results\\$program.tex", append style(tex) type label ///
	unstack collabels(none) ///
	mlabels(, none) ///
	msign(--) ///
	prehead("") ///
	posthead("") ///
	prefoot("\\") ///
	postfoot("\hline" "\hline" ///
	"\end{tabular*}" ///
	"\end{scriptsize}" ///
	"\begin{tablenotes}[normal,flushleft]" ///
	"\begin{scriptsize}" ///
	"\item \emph{Notes}:" /// 
	"Data comes from the \textit{Index of French Nationals Compelled into German Armed Forces}. " ///
	"The upper panel presents the disaggregated (individual) data; " ///
	"the lower panel presents the statistics after collapsing the data at the municipality level. " ///
	"\textit{Residence info}, \textit{Birth info}, and \textit{Born year drafted} are binary variables " ///
	"taking the value 1 when information is available. " ///
	"\textit{Born year drafted} are men born in 1908-1927 for Alsace, and 1914-1927 for Moselle, " ///
	"conditional on birth information being available. " ///
	"\textit{Declared missing (Binary)} and sub-groups " ///
	"are variables that take the value 1 when there is at least one individual in the municipality belonging to this group. " ///	"\textit{Declared missing of whom not drafted (Binary)} includes individuals with birth information missing. " ///
	"\textit{Declared missing (\#)} and sub-groups is the total number of individuals belonging to each category by municipality. " ///
	"\textit{Declared missing (\%)} and sub-groups is the proportion of the 1936 population that appears in the index. " ///
	"\end{scriptsize}" ///
	"\end{tablenotes}" ///
	"\end{threeparttable}" ///
	"\end{center}" ///
	"\end{table}")

cap log close
