{smcl}
{com}{sf}{ul off}{txt}
{com}. 
. **** REPLICATION OF FIGURE B2 ****
. 
. clear all
{res}{txt}
{com}. set mem 2g
{txt}{bf:set memory} ignored.
{p 4 4 2}
Memory no longer
needs to be set in modern Statas;
memory adjustments are performed on the fly
automatically.
{p_end}

{com}. set more off
{txt}
{com}. 
. /*      
>         OUTLINE
>         1. MERGE DATA
>         2. GRAPH
> */
. 
. *************************
. ***** 1. MERGE DATA *****
. *************************
. 
. // Import conscription data
. 
. use $data\EEREV-D-21-00004_Data_Conscription.dta, clear
{txt}
{com}. 
. drop if com==. | birthyear==.
{txt}(816 observations deleted)

{com}. 
. collapse (count) m_all=id, by(dep com birthyear)
{res}{txt}
{com}. 
. tempfile tmp
{txt}
{com}. save `tmp', replace
{txt}{p 0 4 2}
(file {bf}
C:\Users\SVLACHOS\AppData\Local\Temp\ST_3788_000001.tmp{rm}
not found)
{p_end}
{p 0 4 2}
file {bf}
C:\Users\SVLACHOS\AppData\Local\Temp\ST_3788_000001.tmp{rm}
saved
as .dta format
{p_end}

{com}. 
. // Keep municipalities with casualty data
. 
. use $data\EEREV-D-21-00004_Data_Casualties.dta, clear
{txt}
{com}. 
. keep com
{txt}
{com}. duplicates drop

{p 0 4}{txt}Duplicates in terms of {txt} all variables{p_end}

(3,654 observations deleted)

{com}. 
. merge 1:m com using `tmp'
{res}{txt}(label {bf:{txt}com_hist} already defined)
(label {bf:{txt}dep} already defined)

{col 5}Result{col 33}Number of obs
{col 5}{hline 41}
{col 5}Not matched{col 30}{res}          11,141
{txt}{col 9}from master{col 30}{res}               1{txt}  (_merge==1)
{col 9}from using{col 30}{res}          11,140{txt}  (_merge==2)

{col 5}Matched{col 30}{res}           2,378{txt}  (_merge==3)
{col 5}{hline 41}

{com}. drop if _merge!=3
{txt}(11,141 observations deleted)

{com}. drop _merge
{txt}
{com}. 
. tempfile tmp
{txt}
{com}. save `tmp', replace
{txt}{p 0 4 2}
(file {bf}
C:\Users\SVLACHOS\AppData\Local\Temp\ST_3788_000002.tmp{rm}
not found)
{p_end}
{p 0 4 2}
file {bf}
C:\Users\SVLACHOS\AppData\Local\Temp\ST_3788_000002.tmp{rm}
saved
as .dta format
{p_end}

{com}. 
. // Merge with casualty data
. 
. use $data\EEREV-D-21-00004_Data_Casualties.dta, clear
{txt}
{com}. 
. collapse (count) d_all=id, by(dep com birthyear)
{res}{txt}
{com}. 
. merge 1:1 com birthyear using `tmp'
{res}{txt}(label {bf:{txt}com_hist} already defined)
(label {bf:{txt}dep} already defined)

{col 5}Result{col 33}Number of obs
{col 5}{hline 41}
{col 5}Not matched{col 30}{res}             982
{txt}{col 9}from master{col 30}{res}             310{txt}  (_merge==1)
{col 9}from using{col 30}{res}             672{txt}  (_merge==2)

{col 5}Matched{col 30}{res}           1,706{txt}  (_merge==3)
{col 5}{hline 41}

{com}. drop _merge
{txt}
{com}. 
. // Xtset
. 
. xtset com birthyear
{res}
{col 1}{txt:Panel variable: }{res:com}{txt: (unbalanced)}
{p 1 16 2}{txt:Time variable: }{res:birthyear}{txt:, }{res:{bind:0}}{txt: to }{res:{bind:1944}}{txt:, but with gaps}{p_end}
{txt}{col 10}Delta: {res}1 unit
{txt}
{com}. tsfill, full
{txt}
{com}. 
. recode d_all m_all (.=0)
{txt}(435609 changes made to {bf:d_all})
(435247 changes made to {bf:m_all})

{com}. 
. foreach case in all{c -(}
{txt}  2{com}.         g i_`case'=m_`case'*(134000/44034)
{txt}  3{com}.         format i_`case' %9.0f
{txt}  4{com}. {c )-}
{txt}
{com}. 
. save `tmp', replace
{txt}{p 0 4 2}
file {bf}
C:\Users\SVLACHOS\AppData\Local\Temp\ST_3788_000002.tmp{rm}
saved
as .dta format
{p_end}

{com}. 
. // Get 1936 population
. 
. use $data\EEREV-D-21-00004_Data_Municipalities.dta, clear
{txt}
{com}. 
. keep dep com pop_1936
{txt}
{com}. duplicates drop

{p 0 4}{txt}Duplicates in terms of {txt} all variables{p_end}

(11,053 observations deleted)

{com}. 
. merge 1:m com using `tmp'
{res}{txt}(label {bf:{txt}dep} already defined)
(label {bf:{txt}com_hist} already defined)

{col 5}Result{col 33}Number of obs
{col 5}{hline 41}
{col 5}Not matched{col 30}{res}           1,354
{txt}{col 9}from master{col 30}{res}           1,354{txt}  (_merge==1)
{col 9}from using{col 30}{res}               0{txt}  (_merge==2)

{col 5}Matched{col 30}{res}         437,625{txt}  (_merge==3)
{col 5}{hline 41}

{com}. drop if _merge!=3
{txt}(1,354 observations deleted)

{com}. drop _merge
{txt}
{com}. 
. // Group 1890-1905 
. 
. g group=1905 if birthyear<=1905
{txt}(8,775 missing values generated)

{com}. replace group=1930 if birthyear>=1930
{txt}(3,375 real changes made)

{com}. replace group=birthyear if group==.
{txt}(5,400 real changes made)

{com}. 
. collapse (sum) d_all m_all i_all, by(com group pop)
{res}{txt}
{com}. 
. collapse (sum) d_all m_all i_all pop, by(group)
{res}{txt}
{com}. 
. // Get rates
. 
. foreach case in d m i{c -(}
{txt}  2{com}.         g p_`case'=(`case'_all*100)/pop
{txt}  3{com}.         format p_`case' %9.2f
{txt}  4{com}. {c )-}
{txt}
{com}. 
. g p_c=(d_all*100)/i_all
{txt}
{com}. format p_c %9.2f
{txt}
{com}. 
. ********************
. ***** 2. GRAPH *****
. ********************
. 
. // Conscription and casualties
. 
. twoway (bar p_i group, bcolor(navy)) ///
>         (bar p_d group, bcolor(maroon)), ///
>         ytitle("Percent of 1936 population") /// 
>         xtitle("Year of birth") /// 
>         ylabel(0(.2).8, angle(0) format(%5.1f)) ///
>         xlabel(1905 `" "Before" "1906""' 1908 1914 1927 1930 `" "After" "1929""') ///
>         yscale(r(0 .94)) ///
>         legend(label(1 "Conscripted") label(2 "Casualties") r(7) pos(11) ring(0) symx(*0.5) region(col(white))) /// 
>         graphregion(color(white))  name(perc, replace)
{res}{txt}
{com}. 
. // Casualty rate
. 
. twoway (bar p_c group if group>1907 & group<1914, bcolor(maroon)) ///
>         (bar p_c group if group>1913 & group<1928, bcolor(maroon) fi(120)) ///
>         (bar p_c group if group>1927 | group<1908, bcolor(maroon) fi(30)), ///
>         ytitle("Casualty rate (%)") /// 
>         xtitle("Year of birth") /// 
>         ylabel(0(8)32, angle(0) format(%5.0f)) ///
>         xlabel(1905 `" "Before" "1906""' 1908 1914 1927 1930 `" "After" "1929""') ///
>         yscale(r(0 37.6)) ///
>         legend(label(1 "Born 1908-1913") label(2 "Born 1914-1927") label(3 "Other years") r(7) pos(11) ring(0) symx(*0.5) region(col(white))) ///
>         graphregion(color(white))  name(rates, replace)
{res}{txt}
{com}. 
. graph combine perc rates ///
>         , c(2) graphregion(color(white)) imargin(vsmall) //ycommon
{res}{txt}
{com}. graph export "$results\\$program.png", replace width(7200) height(3000)
{txt}{p 0 4 2}
file {bf}
D:\Dropbox\SVLACHOS\Research\Malgre_nous\Replication_files\Results\EEREV-D-21-00004_FigureB2.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. cap log close
{smcl}
{com}{sf}{ul off}