clear clear mata clear matrix set maxvar 10000 * in ... insert the corresponding directory global SAVE .../DataPrepared global USE .../SOEPv35/SOEP_CORE global SOEPLONG .../SOEPv35/SOEP_LONG ********************************************************************************** * SELECTION use $USE/ppfad.dta, clear keep if immiyear!=-2 keep if immiyear>=1990 & immiyear<=2016 keep if arefback==1 // without evidence of refugee experience keep if sex==2 keep if immiyear-gebjahr>=18 keep if immiyear-gebjahr<50 keep persnr immiyear sex corigin gebjahr *VAR: Age at Migration gen AGE_MIG=immiyear-gebjahr lab var AGE_MIG "Age at Migration" *MERGE: Valid birth history merge 1:1 persnr using $USE/biobirth.dta, keep(match) nogenerate keep if kidgeb01!=-1 * Keeping only childless at migration drop if kidgeb01<=immiyear & kidgeb01!=-2 save $SAVE/FIX01.dta, replace ********************************************************************************** *MERGE: Partner's information use $SOEPLONG/pgen.dta, clear keep pid pgpartnr syear * Finding the id number of first partner in their (women's) collected biography gsort pid syear local i=0 while `i'<32 { local INDEX =`i'+1 bys pid: replace pgpartnr= pgpartnr[_n+`INDEX'] if pgpartnr==-2 local i=`i'+1 } bys pid: g SPELL=_n keep if SPELL==1 drop if pgpartnr==-2 | pgpartnr==. * To get migration info of the partner rename pgpartnr persnr merge m:1 persnr using $USE/ppfad.dta keep if _merge==3 drop _merge keep pid persnr immiyear migback sex corigin gebjahr rename persnr P_persnr rename immiyear P_immiyear lab var P_immiyear "Partner's Year of Migration" rename migback P_migback lab var P_migback "Migration background of Partner" rename corigin P_corigin rename gebjahr P_gebjahr * We will only consider male partners keep if sex==1 rename pid persnr keep P_* persnr merge 1:1 persnr using $SAVE/FIX01.dta keep if _merge==3 | _merge==2 drop _merge save $SAVE/FIX02.dta, replace ********************************************************************************** *VAR: Religious affiliation use pid plh0258_h syear using $SOEPLONG/pl.dta , clear rename pid persnr gsort persnr syear bys persnr: g SPELL=_n gen RELIG=. replace RELIG=2 if plh0258_h==1 | plh0258_h==2 | plh0258_h==3 | plh0258_h==7 replace RELIG=1 if plh0258_h==4 | plh0258_h==8 | plh0258_h==9 | plh0258_h==10 replace RELIG=3 if plh0258_h==5 | plh0258_h==11 replace RELIG=4 if plh0258_h==6 lab var RELIG "Religious Affiliation" label def RELIG 1 "Islam" 2 "Christian" 3 "Other" 4 "No religion" lab val RELIG RELIG local i=0 while `i'<32 { local INDEX =`i'+1 by persnr: replace RELIG=RELIG[_n+`INDEX'] if RELIG==. local i=`i'+1 } recode RELIG .=9 keep if SPELL==1 keep persnr RELIG merge 1:1 persnr using $SAVE/FIX02.dta keep if _merge==3 | _merge==2 drop _merge save $SAVE/FIX03.dta, replace ********************************************************************************** *VAR: Education use pgpbbil* pid using $SOEPLONG/pgen.dta, clear rename pid persnr g EDU=-1 replace EDU=2 if pgpbbil01==1 replace EDU=2 if pgpbbil01==2 replace EDU=2 if pgpbbil01==3 replace EDU=2 if pgpbbil01==4 replace EDU=2 if pgpbbil01==5 replace EDU=2 if pgpbbil01==6 replace EDU=2 if pgpbbil01==7 replace EDU=3 if pgpbbil02==1 replace EDU=3 if pgpbbil02==2 replace EDU=3 if pgpbbil02==3 replace EDU=3 if pgpbbil02==4 replace EDU=3 if pgpbbil02==5 replace EDU=3 if pgpbbil02==6 replace EDU=3 if pgpbbil02==7 replace EDU=3 if pgpbbil02==8 replace EDU=3 if pgpbbil02==9 replace EDU=3 if pgpbbil02==10 replace EDU=1 if pgpbbila==1 replace EDU=2 if pgpbbila==2 replace EDU=2 if pgpbbila==3 replace EDU=3 if pgpbbila==4 replace EDU=-1 if pgpbbila==5 replace EDU=2 if pgpbbila==6 replace EDU=3 if pgpbbila==7 replace EDU=2 if pgpbbila==8 replace EDU=3 if pgpbbila==9 replace EDU=2 if pgpbbila==11 replace EDU=2 if pgpbbila==12 replace EDU=2 if pgpbbila==13 replace EDU=3 if pgpbbila==14 replace EDU=-1 if pgpbbila==15 replace EDU=2 if pgpbbila==16 replace EDU=3 if pgpbbila==17 replace EDU=3 if pgpbbila==19 replace EDU=1 if pgpbbil03==1 replace EDU=2 if pgpbbil03==2 replace EDU=3 if pgpbbil03==3 bys persnr: egen EDUMAX=max(EDU) recode EDUMAX -1=9 lab var EDUMAX "Highest Level of Eductaion" lab def EDUMAX 1 "Low" 2 "Medium" 3 "High" lab val EDUMAX EDUMAX bys persnr: g SPELL=_n keep if SPELL==1 keep EDUMAX persnr merge 1:1 persnr using $SAVE/FIX03.dta keep if _merge==3 drop _merge save $SAVE/FIX04.dta, replace ************************************************************************** *MARITAL HISTORY use $USE/ppfad.dta, clear keep persnr immiyear gebjahr merge 1:m persnr using $USE/biomarsy.dta keep if immiyear>0 keep persnr begin beginy end spelltyp immiyear gebjahr bys persnr: egen TEST=max(end) bys persnr: egen BEGIN0=min(begin) * copy gen BEGINmin=BEGIN0 bys persnr: egen minYEAR=min(beginy) drop beginy * dropping those with missing histories drop if TEST==. drop if BEGIN0<0 | BEGIN0==. drop if minYEAR<0 bys persnr: g SPELL=_n reshape wide begin end spelltyp, i(persnr) j(SPELL) g TEST01=0 replace TEST=TEST+.01 stset TEST, fail(TEST01) id(persnr) time0(BEGIN0) stsplit TEST02, every(1) *** VAR: MARRITAL HISTORY gen UNMARRIED=0 local i=0 while `i'<8 { local INDEX = `i'+1 replace UNMARRIED=1 if begin`INDEX'<=_t0 & _t<= end`INDEX' & spelltyp`INDEX'==1 replace UNMARRIED=1 if begin`INDEX'==_t0 & spelltyp`INDEX'==1 replace UNMARRIED=1 if end`INDEX'==_t0 & spelltyp`INDEX'==1 local i=`i'+1 } gen MARRIED=0 local i=0 while `i'<8 { local INDEX = `i'+1 replace MARRIED=1 if begin`INDEX'<=_t0 & _t<= end`INDEX' & spelltyp`INDEX'==2 replace MARRIED=1 if begin`INDEX'==_t0 & spelltyp`INDEX'==2 replace MARRIED=1 if end`INDEX'==_t0 & spelltyp`INDEX'==2 local i=`i'+1 } gen OTHERPOSTM=0 local i=0 while `i'<8 { local INDEX = `i'+1 replace OTHERPOSTM=1 if begin`INDEX'<=_t0 & _t<= end`INDEX' & (spelltyp`INDEX'==3 | spelltyp`INDEX'==4 | spelltyp`INDEX'==5 | spelltyp`INDEX'==6 | spelltyp`INDEX'==7) replace OTHERPOSTM=1 if begin`INDEX'==_t0 & (spelltyp`INDEX'==3 | spelltyp`INDEX'==4 | spelltyp`INDEX'==5 | spelltyp`INDEX'==6 | spelltyp`INDEX'==7) replace OTHERPOSTM=1 if end`INDEX'==_t0 & (spelltyp`INDEX'==3 | spelltyp`INDEX'==4 | spelltyp`INDEX'==5 | spelltyp`INDEX'==6 | spelltyp`INDEX'==7) local i=`i'+1 } gen GAP=0 local i=0 while `i'<8 { local INDEX = `i'+1 replace GAP=1 if begin`INDEX'<=_t0 & _t<= end`INDEX' & spelltyp`INDEX'==9 replace GAP=1 if begin`INDEX'==_t0 & spelltyp`INDEX'==9 replace GAP=1 if end`INDEX'==_t0 & spelltyp`INDEX'==9 local i=`i'+1 } * VAR: Marrital Status (Hierarchy) gen TYP=. replace TYP=9 if GAP==1 replace TYP=3 if OTHERPOSTM==1 replace TYP=1 if UNMARRIED==1 replace TYP=2 if MARRIED==1 * YEAR in the history sort persnr _t0 gen toadd= _t0-BEGINmin gen YEAR=minYEAR + toadd * VAR: Age at first marriage gen agemar=_t0 if TYP==2 bys persnr: egen AGEFMAR=min(agemar) replace AGEFMAR=99 if AGEFMAR==. * VAR: Year of first marriage gen yearmar=YEAR if TYP==2 bys persnr: egen YEARFMAR=min(yearmar) replace YEARFMAR=99 if YEARFMAR==. * VAR: Ever divorced gen pm=1 if TYP==3 bys persnr: egen EVERDIVORCED=max(pm) replace EVERDIVORCED=0 if EVERDIVORCED==. * VAR: Marrital status at migration gen AGE_MIG=immiyear-gebjahr g MARR01=-1 replace MARR01=0 if TYP==1 & AGE_MIG==_t0 replace MARR01=1 if TYP==2 & AGE_MIG==_t0 replace MARR01=2 if TYP==3 & AGE_MIG==_t0 bys persnr: egen MARR=max(MARR01) recode MARR -1=9 lab var MARR "Marital Status at Migration" label def MARR 0 "Single" 1 "Married" 2 "Other (Divorced, Widowed etc)" label val MARR MARR by persnr: g SPELL02=_n keep if SPELL02==1 * FOR THOSE MARRIED AT MIGRATION: TIME MARRIED IN RELATION TO MIGRATION gen MARTIME=99 if MARR!=1 replace MARTIME=AGEFMAR-AGE_MIG if MARR==1 keep persnr MARR MARTIME AGEFMAR YEARFMAR EVERDIVORCED merge 1:1 persnr using $SAVE/FIX04.dta keep if _merge==3 drop _merge save $SAVE/FIX05.dta, replace ************************************************************************** * Idenfiying ethnic Germans use $SAVE/FIX05.dta, clear merge 1:m persnr using $USE/migspell.dta, keep if _merge==1 | _merge==3 drop _merge gen ethg=1 if status1==1 replace ethg=0 if ethg==. bys persnr: egen EGERM=max(ethg) bys persn: gen sp=_n keep if sp==1 replace EGERM=0 if EGERM==. keep persnr EGERM save $SAVE/EGERM.dta, replace use $SAVE/FIX05.dta, clear drop pid gen long pid=persnr merge 1:m pid using $SOEPLONG/pl.dta, keep(match) nogenerate *VAR: Aussiedler gen AUS1=1 if plj0006==1 bys pid: egen AUS= max(AUS1) bys pid: gen sp=_n keep if sp==1 keep persnr AUS plm0224 save $SAVE/GN.dta, replace use $SAVE/FIX05.dta, clear merge 1:1 persnr using $SAVE/EGERM.dta drop _merge merge 1:1 persnr using $SAVE/GN.dta drop _merge save $SAVE/FIX06.dta, replace ************************************************************************** * COUNTRY OF ORIGIN *** VAR: Regions of origin * https://www.bmas.de/EN/Our-Topics/Labour-Market/employment-of-foreigners.html * https://en.wikipedia.org/wiki/Freedom_of_movement_for_workers_in_the_European_Union use $SAVE/FIX06.dta, clear gen COREGION=. replace COREGION=1 if corigin==3 | corigin==21 | corigin==22 | corigin==26 /// | corigin==29 | corigin==31 | corigin==32 | corigin==73 | corigin==74 | corigin==75 | corigin==77 /// | corigin== 78 | corigin==82 | corigin==97 | corigin==101 | corigin== 103 /// | corigin==119 | corigin==120 | corigin==121 | corigin==122 | corigin==123 /// | corigin==130 | corigin==132 | corigin==140 | corigin==141 | corigin==146 /// | corigin==148 | corigin==155 | corigin==165 | corigin==168 | corigin==222 replace COREGION=2 if corigin==4 | corigin==5 | corigin==6 | corigin==10 | corigin==11 /// | corigin==12 | corigin==13 | corigin==14 | corigin==15 | corigin==16 | corigin==17 /// | corigin== 19 | corigin==28 | corigin==71 | corigin==116 /// | corigin== 117 | corigin==118 replace COREGION=3 if corigin==47 | corigin==49 | corigin==52 | corigin ==53 | corigin==54 /// | corigin==57 | corigin==67 | corigin==79 | corigin==80 | corigin==81 | corigin==84 /// | corigin== 86 | corigin== 89 | corigin== 94 | corigin== 95 | corigin== 102 | corigin== 105 /// | corigin== 110 | corigin==111 | corigin==113 | corigin==135 | corigin==138 | corigin==139 /// | corigin==142 | corigin==143 | corigin==144 | corigin==147 | corigin==150 | corigin==156 /// | corigin==158 | corigin==166 | corigin==173 | corigin==176 | corigin==178 | corigin==183 | corigin==37 replace COREGION=4 if corigin==24 | corigin==30 | corigin==39 | corigin==46 | corigin==60 /// | corigin== 76 | corigin==87 | corigin==90 | corigin==126 | corigin==149 /// | corigin==151 | corigin==152 replace COREGION=5 if corigin==23 | corigin==25 | corigin==38 | corigin==40 | corigin==42 /// | corigin== 43 | corigin==44 | corigin==50 | corigin==63 | corigin==65 | corigin==66 /// | corigin== 68 | corigin==83 | corigin==85 | corigin==93 | corigin==100 | corigin==128 /// | corigin==145 | corigin==154 | corigin==169 | corigin==181 replace COREGION=6 if corigin==2 replace COREGION=7 if corigin==18 | corigin==20 | corigin==27 | corigin==34 /// | corigin== 35 | corigin==41 | corigin==45 | corigin==48 | corigin==51 /// | corigin==55 | corigin==56 | corigin==59 | corigin==61 | corigin==64 /// | corigin==88 | corigin==92 | corigin==96 | corigin==108 | corigin==109 /// | corigin==115 | corigin==124 | corigin==125 | corigin==129 | corigin==133 /// | corigin==157 | corigin==167 | corigin==171 | corigin==170 gen COREGION2=. replace COREGION2=1 if COREGION==1 replace COREGION2=2 if COREGION==2 replace COREGION2=3 if COREGION==3 | COREGION==4 | COREGION==6 replace COREGION2=4 if COREGION==5 | COREGION==7 lab var COREGION2 "Region of Origin" label def coregion2 1 "CEE" 2 "Western Europe" 3 "Africa + Middle East" 4 "Other" label val COREGION2 coregion2 * Freedom of movement only since 1994 * 10 Austria, 17 Finland, 15 Sweden, 16 Norway, 70 Iceland gen NFM1994=1 if immiyear<1994 & (corigin==10 | corigin==17 | corigin==15 | corigin==16 | corigin==70) * Freedom of movement only since 2004 * 19 swizerland gen NFM2004=1 if immiyear<=2004 & corigin==19 * New members of the EU freemovement in Germany (for employment) * from 2011: 101 Estonia, 103 Latvia, 146 Lithuania, 22 Poland, 26 Hungry, 31 Czech Republic, 123 Slovakia, 122 Slovenia gen NEWEU2011=0 replace NEWEU2011=1 if immiyear>=2011 & (corigin==101 | corigin==103 | corigin==146 | corigin==22 | /// corigin==26 | corigin==31 | corigin==123 | corigin==122) * from 2014: 29 Bulgaria and 21 Romania gen NEWEU2014=0 replace NEWEU2014=1 if immiyear>=2014 & (corigin==29 | corigin==21) * Considering those who arrived with the freedom of movement gen COREGION3=. replace COREGION3=1 if COREGION==1 replace COREGION3=2 if COREGION==2 replace COREGION3=3 if COREGION==3 | COREGION==4 | COREGION==6 replace COREGION3=4 if COREGION==5 | COREGION==7 replace COREGION3=0 if NEWEU2011==1 | NEWEU2014==1 lab var COREGION3 "Region of Origin" label def coregion3 0 "CEE FM" 1 "CEE" 2 "Western Europe" 3 "Africa + Middle East" 4 "Other" label val COREGION3 coregion3 * Including the ones of freedom of movement in the category with Western EU gen COREGION4=. replace COREGION4=1 if COREGION==1 replace COREGION4=2 if COREGION==2 | NEWEU2011==1 | NEWEU2014==1 replace COREGION4=3 if COREGION==3 | COREGION==4 | COREGION==6 replace COREGION4=4 if COREGION==5 | COREGION==7 lab var COREGION4 "Right of movement" label def coregion4 1 "CEE" 2 "EU Freedom of movement" 3 "Africa + Middle East" 4 "Other" label val COREGION4 coregion4 gen COREGION5=COREGION3 replace COREGION5=5 if AUS==1 | EGERM==2 lab var COREGION5 "Right of movement" label def coregion5 0 "FM CEE" 1 "CEE" 2 "EU West + South" 3 "Africa + Middle East" 4 "Other" 5 "CEE GNAT" label val COREGION5 coregion5 gen COREGION6=COREGION5 replace COREGION6=2 if COREGION5==0 | COREGION5==5 label val COREGION6 coregion4 save $SAVE/FIX07.dta, replace ****************************************************************************** use $SAVE/FIX07.dta, clear ** VAR: Type of husband (relative migration year) gen MART=9 replace MART=1 if MARR==0 replace MART=2 if MARR==1 & (P_migback==1 | P_migback==3) replace MART=4 if MARR==1 & P_migback==2 & immiyear>P_immiyear & P_immiyear >0 replace MART=3 if MARR==1 & P_migback==2 & (immiyear==P_immiyear) & P_immiyear >0 replace MART=3 if MARR==1 & P_migback==2 & (immiyear==P_immiyear+1 | immiyear==P_immiyear+2) & P_immiyear >0 lab var MART "Type of husband" lab def MART 1 "Single at migration" /// 2 "Husband German & German born" /// 3 "Tied mover (+2 year)" /// 4 "Man migrated first" lab val MART MART * Type of husband (relative migration year), excluding divorced gen MART2=MART replace MART2=9 if EVERDIVORCED==1 & MART!=1 lab val MART2 MART ** VAR: Type of husband marriage time (relative marital year and year of migration of husband gen diffpm = P_immiyear - YEARFMAR if YEARFMAR!=99 & P_immiyear>0 replace diffpm=99 if diffpm==. gen MARTIMEP=1 if diffpm >=0 & diffpm!=99 replace MARTIMEP=2 if diffpm <0 replace MARTIMEP=3 if MARTIMEP==. label def MARTIMEP 1 "married before he migrated" 2 "married after he migrated" 3 "other" label val MARTIMEP MARTIMEP gen MARTP=9 replace MARTP=1 if MARR==0 replace MARTP=2 if MARR==1 & (P_migback==1 | P_migback==3) replace MARTP=4 if MARR==1 & MARTIMEP==2 replace MARTP=3 if MARR==1 & MARTIMEP==1 lab var MARTP "Husband and migration time" lab def MARTP 1 "Single at migration" /// 2 "Husband German & German born" /// 3 "Married before H migrated" /// 4 "Married after H migrated" lab val MARTP MARTP * case when there was a divorce in the lc gen MARTP2=MARTP replace MARTP2=9 if EVERDIVORCED==1 & MARTP!=1 lab val MARTP2 MARTP * cases when married and man followed wife gen MANFOLLOW=1 if MARR==1 & P_immiyear>immiyear replace MANFOLLOW=0 if MANFOLLOW==. keep persnr corigin COREGION2 COREGION3 COREGION4 COREGION5 EVERDIVORCED COREGION6 gebjahr AGE_MIG EDUMAX RELIG MART MART2 MARR MARTP MARTP2 MARTIME MARTIMEP AGEFMAR YEARFMAR immiyear kidgeb01 kidgeb02 kidgeb03 plm0224 bioage MANFOLLOW save $SAVE/FIX08.dta, replace ************************************************************* *SELECTION: ONLY CHILDLESS WOMEN AT MIGRATION use $SAVE/FIX08.dta, clear drop if kidgeb01<=immiyear & kidgeb01!=-2 save $SAVE/FIX09.dta, replace ************************************************************* *** EVENT HISTORY DATA: CLEAN EMPLOYMENT + EDUCATION HISTORY * We give priority to employment in the hierarchy use $USE/ppfad.dta, clear keep persnr immiyear gebjahr merge 1:m persnr using $USE/pbiospe.dta keep if immiyear>0 keep persnr begin end spelltyp erhebj bys persnr: egen TEST=max(end) bys persnr: egen BEGIN0=min(begin) * droping those with missing histories drop if TEST==. drop if BEGIN==. bys persnr: g SPELL=_n reshape wide begin end spelltyp, i(persnr) j(SPELL) g TEST01=0 replace TEST=TEST+.01 stset TEST, fail(TEST01) id(persnr) time0(BEGIN0) stsplit TEST02, every(1) * In Employment Full-time or Part-time Employment gen EMPLOYMENT=0 local i=0 while `i'<25 { local INDEX = `i'+1 replace EMPLOYMENT=1 if begin`INDEX'<=_t0 & _t<= end`INDEX' & (spelltyp`INDEX'==4 | spelltyp`INDEX'==5) replace EMPLOYMENT=1 if begin`INDEX'==_t0 & (spelltyp`INDEX'==4 | spelltyp`INDEX'==5) replace EMPLOYMENT=1 if end`INDEX'==_t0 & (spelltyp`INDEX'==4 | spelltyp`INDEX'==5) local i=`i'+1 } * In Education gen EDUCATION=0 local i=0 while `i'<25 { local INDEX = `i'+1 replace EDUCATION=1 if begin`INDEX'<=_t0 & _t<= end`INDEX' & (spelltyp`INDEX'==1 | spelltyp`INDEX'==2 ) replace EDUCATION=1 if begin`INDEX'==_t0 & (spelltyp`INDEX'==1 | spelltyp`INDEX'==2 ) replace EDUCATION=1 if end`INDEX'==_t0 & (spelltyp`INDEX'==1 | spelltyp`INDEX'==2 ) local i=`i'+1 } * Var: TYP (hierarchy) gen TYP=. replace TYP=1 if EDUCATION==1 replace TYP=2 if EMPL==1 replace TYP=9 if TYP==. merge m:1 persnr using $SAVE/FIX09.dta keep if _merge==3 drop _merge save $SAVE/LONG01.dta, replace *** VAR: YEARS WORK EXPERIENCE BEFORE MIGRATION use $SAVE/LONG01.dta, clear * keeping only history before migration keep if AGE_MIG>_t0 bys persnr: egen YEARSEMPBM=sum(EMPLOYMENT) * select bys persnr: gen SPELL=_n keep if SPELL==1 keep persnr YEARSEMPBM merge 1:m persnr using $SAVE/LONG01.dta, nogenerate keep(match) bys persnr: gen SPELL=_n drop SPELL save $SAVE/LONG02.dta, replace bys persnr: gen sp=_n *** EVENT HISTORY DATA: Data Pro use $SAVE/LONG02.dta, clear *SELECTION: Eliminate Time Before Migration drop if AGE_MIG>_t0 *SELECTION: those with valid marrital histories in the year of migration drop if MARR>8 * SELECTION: those who were married or single drop if MARR==2 *SELECTION: Eliminate Respondents who are in Education the year after migration g TEST03=. *replace TEST01=1 if immiyear+1==_t0 & TYP==1 replace TEST03=1 if AGE_MIG+1==_t0 & TYP==1 bys persnr: egen INEDU=min(TEST03) drop if INEDU==1 *Recode the Labor Market Status in Year of Migration to "Not employed" replace TYP=9 if AGE_MIG==_t0 *VAR: Adjust Time Variable (TIME: Time since Migration) bys persnr: egen TEST04=min(_t0) generate TIME=_t0-TEST04 generate DUR=. replace DUR=0 if TIME==0 replace DUR=1 if TIME==1 replace DUR=2 if TIME==2 replace DUR=3 if TIME==3 replace DUR=3 if TIME==4 replace DUR=3 if TIME==5 replace DUR=4 if TIME>5 lab var DUR "Time since Migration" lab def DUR 0 "0" 1 "1" 2 "2" 3 "3-5" 4 "5+" lab val DUR DUR *VAR: EVENT generate EVENT=0 replace EVENT=1 if TYP==2 * VAR: YEAR Time Varying gen YEAR=immiyear+TIME *VAR: Children generate KID=9 replace KID=0 if YEAR=kidgeb01 & kidgeb01!=-2 replace KID=0 if kidgeb01==-2 *replace KID=9 if kidgeb01==-1 lab var KID "Kid?" lab def KID 1 "yes" 0 "no" lab val KID KID *VAR: Age of First Child g AGEKID01=YEAR-kidgeb01 generate KID01=. replace KID01=0 if YEAR=0 replace KID01=2 if AGEKID01>2 replace KID01=3 if AGEKID01>4 replace KID01=4 if AGEKID01>6 replace KID01=0 if kidgeb01==-2 lab var KID01 "Age first child?" lab def KID01 0 "childless" 1 "0-2" 2 "3-4" 3 "5-6" 4 "7+" lab val KID01 KID01 *VAR: Age of Second Child g AGEKID02=YEAR-kidgeb02 generate KID02=. replace KID02=0 if YEAR=0 replace KID02=2 if AGEKID02>2 replace KID02=3 if AGEKID02>4 replace KID02=4 if AGEKID02>6 replace KID02=0 if kidgeb02==-2 lab var KID02 "Age second child?" lab def KID02 0 "no second child" 1 "0-2" 2 "3-4" 3 "5-6" 4 "7+" lab val KID02 KID02 *VAR: Age of Third Child g AGEKID03=YEAR-kidgeb03 generate KID03=. replace KID03=0 if YEAR=0 replace KID03=2 if AGEKID03>2 replace KID03=3 if AGEKID03>4 replace KID03=4 if AGEKID03>6 replace KID03=0 if kidgeb03==-2 lab var KID03 "Age third child?" lab def KID03 0 "no third child" 1 "0-2" 2 "3-4" 3 "5-6" 4 "7+" lab val KID03 KID03 *VAR: Age of Youngest Child g AGEYKID=KID01 replace AGEYKID=KID02 if KID02!=0 replace AGEYKID=KID03 if KID03!=0 lab val AGEYKID KID01 * VAR: Number of children gen NKID=0 if KID01==0 replace NKID=1 if KID01!=0 & KID02==0 replace NKID=2 if KID02!=0 & KID03==0 replace NKID=3 if KID03!=0 lab def NKID 0 "childless" 1 "1" 2 "2" 3 "3" * VAR: NCHILD and AGEYCHID gen NKIDAGEY=0 if NKID==0 replace NKIDAGEY=11 if NKID==1 & AGEYKID==1 replace NKIDAGEY=12 if NKID==1 & AGEYKID==2 replace NKIDAGEY=13 if NKID==1 & AGEYKID==3 replace NKIDAGEY=14 if NKID==1 & AGEYKID==4 replace NKIDAGEY=21 if NKID==2 & AGEYKID==1 replace NKIDAGEY=22 if NKID==2 & AGEYKID==2 replace NKIDAGEY=23 if NKID==2 & AGEYKID==3 replace NKIDAGEY=24 if NKID==2 & AGEYKID==4 replace NKIDAGEY=31 if NKID==3 & AGEYKID==1 replace NKIDAGEY=32 if NKID==3 & AGEYKID==2 replace NKIDAGEY=33 if NKID==3 & AGEYKID==3 replace NKIDAGEY=34 if NKID==3 & AGEYKID==4 lab def NKIDAGEY 0 "Childless" 11 "1: 0-2" 12 "1: 3-4" 13 "1: 5-6" 14 "1: 7+" /// 21 "2: 0-2" 22 "2: 3-4" 23 "2: 5-6" 24 "2: 7+" /// 31 "3: 0-2" 32 "3: 3-4" 33 "3: 5-6" 34 "3: 7+" /// lab val NKIDAGEY NKIDAGEY * YEAR MIG generate YEAR_MIG=. replace YEAR_MIG=1 if immiyear>=1990 replace YEAR_MIG=2 if immiyear>=2000 replace YEAR_MIG=3 if immiyear>=2007 lab var YEAR_MIG "Year of Migration" lab def YEAR_MIG 1 "1990-1999" 2 "2000-2006" 3 "2007-2015" lab val YEAR_MIG YEAR_MIG *SELECTION: Drop Event after first employment sort persnr YEAR local i=0 while `i'<100 { local INDEX =`i'+1 by persnr: drop if EVENT[_n-1]==1 local i=`i'+1 } * CENSORING: Drop observations after persons were last interviewed gen AGEEM=erhebj-gebjahr gen TIMESM=AGEEM-AGE_MIG bys persnr: egen TIMEMAX=max(TIME) *gen dif=TIMESM-TIMEMAX drop if TIME>TIMESM & EVENT==0 * MAR TIME VARYING sort persnr _t0 gen MAR=0 if MART2==1 replace MAR=1 if MART2>1 & MART2<8 replace MAR=2 if _t0>=AGEFMAR & MAR==. gen MAR2=MART2 replace MAR2=5 if _t0>=AGEFMAR & MART2==1 lab def MAR2 1 "Single at migration" /// 2 "Husband German & German born" /// 3 "Tied mover (+2 year)" /// 4 "Marriage migrant" /// 5 "Married after migration" lab val MAR2 MAR2 gen MARF=1 if MAR2==5 & TIME<=11 replace MARF=0 if MARF==. bys persnr: egen MARAM=max(MARF) gen MAR3=MAR2 replace MAR3=5 if MARF==1 label val MAR3 MAR2 * SELECTION: excluding those who only have the year of migration as a record bys persnr: g nSPELL=_N drop if nSPELL==1 * SELECTION: delete Partners invalid immiyear drop if MART==9 & MANFOLLOW==0 * SELECTION: delete Partners who were German born drop if MART==2 * SELECTION: cases when man followed wife drop if MANFOLLOW==1 * SELECTION those who ever divorced drop if MARR==1 & EVERDIVORCED==1 *VAR: Spell bys persnr: g SPELL=_n *SELECTION: Variables drop spelltyp1-end26 TEST begin1-spelltyp25 nSPELL TEST* *VAR: AGE entered employment in Germany gen AGE_EMP=AGE_MIG+TIME if EVENT==1 save $SAVE/FINAL.dta, replace ************* RESULTS*********************************************************** ******************************************************************************** *** Keeping single women and foreign partnerships log using $SAVE/FINAL_TOPUBLISH.log, replace use $SAVE/FINAL.dta, clear keep if MART2==3 | MART2==4 | MART2==1 drop if TIME==0 bys persn: g SPELL01=_n *** Descriptive table I tab MART2 if SPELL01==1 tab YEAR_MIG MART2 if SPELL01==1, nof col tab COREGION6 MART2 if SPELL01==1, nof col tab EDUMAX MART2 if SPELL01==1, nof col tab RELIG MART2 if SPELL01==1, nof col mean AGE_MIG YEARSEMPBM if SPELL01==1, over(MART2) *** Descriptive table II tab TIME KID if MART2==1, nof row tab TIME KID if MART2==3, nof row tab TIME KID if MART2==4, nof row *KM-curves g END2=TIME+1 stset END2, fail(EVENT) time0(TIME) id(persnr) exit(time 11) sts list, by(MART2) compare sts graph, by(MART2) *** Figure I: life table curves use $SAVE/FINAL.dta, clear keep if MART2==3 | MART2==4 | MART2==1 bys persn: g SPELL01=_n gen testLTIME=TIME if EVENT==1 bys persnr: egen LTIME=min(testLTIME) replace LTIME=11 if LTIME==. bys persnr: egen LEVENT=max(EVENT) * select bys persnr: gen sp=_n keep if sp==2 *keep persnr LTIME LEVENT MART keep persnr LTIME LEVENT MART2 stset LTIME, fail(LEVENT) exit(time 11) ltable _t _d, by(MART2) survival *** Table III: Models use $SAVE/FINAL.dta, clear keep if MART2==3 | MART2==4 | MART2==1 drop if TIME==0 cloglog EVENT ib1.DUR ib2.YEAR_MIG AGE_MIG ib3.MART2 , eform est store MODEL1 cloglog EVENT ib1.DUR ib2.YEAR_MIG AGE_MIG ib3.MART2 ib1.COREGION6, eform est store MODEL2 cloglog EVENT ib1.DUR ib2.YEAR_MIG AGE_MIG ib3.MART2 ib1.COREGION6 ib1.EDUMAX YEARSEMPBM, eform est store MODEL3 cloglog EVENT ib1.DUR ib2.YEAR_MIG AGE_MIG ib3.MART2 ib1.COREGION6 ib1.EDUMAX YEARSEMPBM ib1.KID, eform est store MODEL4 estimates table MODEL*, star(.05 .01 .001) eform b(%9.2f) *** Figure II: Predicted probabilties interaction Childbirth and migration pattern group cloglog EVENT ib1.DUR ib1.KID#ib3.MART2 ib2.YEAR_MIG AGE_MIG ib1.COREGION6 ib1.EDUMAX YEARSEMPBM , eform margins ib1.KID#ib3.MART2 marginsplot ******** Data for Competing risks table/plots use $SAVE/FINAL.dta, clear ** Competing risks: change order for robustness gen EVENTCR=0 if EVENT==0 replace EVENTCR=2 if KID==1 replace EVENTCR=1 if EVENT==1 *SELECTION: Drop Event after first childbirth sort persnr YEAR local i=0 while `i'<100 { local INDEX =`i'+1 by persnr: drop if EVENTCR[_n-1]==1 | EVENTCR[_n-1]==2 local i=`i'+1 } save $SAVE/FINALCR.dta, replace **** Figure II: Competing Risks Plots ****************** * stcompet: stcompet.pkg, from ttp://fmwww.bc.edu/RePEc/bocode/s/ ** Competing Risks plot: Singles use $SAVE/FINALCR.dta, clear g END2=TIME+1 drop TIME gen TIME=END2 keep if MART2==1 *gen TIME=END2 stset TIME, fail(EVENTCR==1) id(persnr) exit (time 10) cap drop Cum* cap drop Cum* stcompet SURVIVAL=ci , compet1(2) sort _t SURVIVAL by _t SURVIVAL: g SPELL01=_n keep if SPELL01==1 keep SURVIVAL _t EVENTCR replace _t=0 if _t<1 save $SAVE/JUNK, replace *Cosmetics: Make Output Look Nice clear set obs 11 g _t=_n save $SAVE/BLANKFILE, replace use $SAVE/JUNK, clear keep if EVENTCR==1 rename SURVIVAL SURVIVAL01 save $SAVE/JUNK02, replace use $SAVE/JUNK, clear keep if EVENTCR==2 drop if SURVIVAL==. merge _t using $SAVE/JUNK02, sort drop _merge EVENTCR merge _t using $SAVE/BLANKFILE , sort sort _t replace SURVIVAL=SURVIVAL[_n-1] if SURVIVAL[_n-1]!=. & SURVIVAL==. replace SURVIVAL01=SURVIVAL01[_n-1] if SURVIVAL01[_n-1]!=. & SURVIVAL01==. recode SURVIVAL .=0 recode SURVIVAL01 .=0 l _t SURVIVAL01 SURVIVAL, clean noobs line SURVIVAL* _t ** Competing Risks plot: Spousal Migrant use $SAVE/FINALCR.dta, clear g END2=TIME+1 drop TIME gen TIME=END2 keep if MART2==3 *gen TIME=END2 stset TIME, fail(EVENTCR==1) id(persnr) exit (time 10) cap drop Cum* cap drop Cum* stcompet SURVIVAL=ci , compet1(2) sort _t SURVIVAL by _t SURVIVAL: g SPELL01=_n keep if SPELL01==1 keep SURVIVAL _t EVENTCR replace _t=0 if _t<1 save $SAVE/JUNK, replace *Cosmetics: Make Output Look Nice clear set obs 11 g _t=_n save $SAVE/BLANKFILE, replace use $SAVE/JUNK, clear keep if EVENTCR==1 rename SURVIVAL SURVIVAL01 save $SAVE/JUNK02, replace use $SAVE/JUNK, clear keep if EVENTCR==2 drop if SURVIVAL==. merge _t using $SAVE/JUNK02, sort drop _merge EVENTCR merge _t using $SAVE/BLANKFILE , sort sort _t replace SURVIVAL=SURVIVAL[_n-1] if SURVIVAL[_n-1]!=. & SURVIVAL==. replace SURVIVAL01=SURVIVAL01[_n-1] if SURVIVAL01[_n-1]!=. & SURVIVAL01==. recode SURVIVAL .=0 recode SURVIVAL01 .=0 l _t SURVIVAL01 SURVIVAL, clean noobs line SURVIVAL* _t ** Competing Risks plot: Marriage migrants use $SAVE/FINALCR.dta, clear g END2=TIME+1 drop TIME gen TIME=END2 keep if MART2==4 stset TIME, fail(EVENTCR==1) id(persnr) exit (time 10) cap drop Cum* cap drop Cum* stcompet SURVIVAL=ci , compet1(2) sort _t SURVIVAL by _t SURVIVAL: g SPELL01=_n keep if SPELL01==1 keep SURVIVAL _t EVENTCR replace _t=0 if _t<1 save $SAVE/JUNK, replace *Cosmetics: Make Output Look Nice clear set obs 11 g _t=_n save $SAVE/BLANKFILE, replace use $SAVE/JUNK, clear keep if EVENTCR==1 rename SURVIVAL SURVIVAL01 save $SAVE/JUNK02, replace use $SAVE/JUNK, clear keep if EVENTCR==2 drop if SURVIVAL==. merge _t using $SAVE/JUNK02, sort drop _merge EVENTCR merge _t using $SAVE/BLANKFILE , sort sort _t replace SURVIVAL=SURVIVAL[_n-1] if SURVIVAL[_n-1]!=. & SURVIVAL==. replace SURVIVAL01=SURVIVAL01[_n-1] if SURVIVAL01[_n-1]!=. & SURVIVAL01==. recode SURVIVAL .=0 recode SURVIVAL01 .=0 l _t SURVIVAL01 SURVIVAL, clean noobs line SURVIVAL* _t log close