* Replace "DIRECTORY" in the global "user" with own directory
global user "DIRECTORY"
global dataset "DIRECTORY\dataset"
global output "DIRECTORY\output"

/// GENERAL DATASET DEFINITION
use "$dataset\census 2000original.dta", clear

label define spralabel 110 "German" 120 "French" 130 "Italian" 140 "Romansh" 210 "English" 220 "Dutch" 230 "Scandinavian" 240 "Greek" 250 "Spanish" 270 "Slavic" 290 "Czech and Slovak" 284 "Hungarian" 300 "Other languages"

label values spra spralabel

* Definition of languages categories
gen spklang="German" if spra==110
replace spklang="French" if spra==120
replace spklang="Italian" if spra==130
replace spklang="Romansh" if spra==140
replace spklang="English" if spra==210
replace spklang="Dutch" if spra==220
replace spklang="Swedish" if spra==230 & gort==8234
replace spklang="Danish" if spra==230 & gort==8206
replace spklang="Greek" if spra==240
replace spklang="Spanish" if spra==250
replace spklang="Czech" if spra==290
replace spklang="Hungarian" if spra==284
replace spklang="Yugoslavian" if spra==270 & gort==8220

///identification of mother tongue by census' "other languages" category and birthplace variable

replace spklang="Portuguese" if spra==300 & (gort==8231|nati==8231)
replace spklang="Finnish" if spra==300 & (gort==8211|nati==8211)
replace spklang="Romanian" if spra==300 & (gort==8232|nati==8232)
replace spklang="Turkish" if spra==300 & (gort==8239|nati==8239)
replace spklang="Mandarin" if spra==300 & (gort==8508|nati==8508)
replace spklang="Japanese" if spra==300 & (gort==8515|nati==8515)
replace spklang="Arabic" if spra==300 & (gort==8523|gort==8304|gort==8357|nati==8523|nati==8304|nati==8357)
replace spklang="Vietnamese" if spra==300 & (gort==8545|nati==8545)
replace spklang="Persian" if spra==300 & (gort==8513|nati==8513)
replace spklang="Hebrew" if spra==300 & (gort==8514|nati==8514)

* merging with Chen's dataset on languages' future reference
merge m:1 spklang using "$dataset\chen language ftr.dta", gen(merge_ftr)
drop if merge_ftr==2
drop merge_ftr

*generation of age squared variable
gen altj2=(altj)^2

* generation of female dummy (0 = male; 1 = female)
gen double female=0 if gesl==1

replace female=1 if gesl==2

* generation of labour market participation dummy
gen double active=0 

replace active=1 if ams<=20

* generation of labour market participation dummy
gen double employed=0

replace employed=1 if ams<=14

* generation of sector of occupation dummies (1 = agriculture; 2 = industry; 3 = services)
gen double worksector=1 if wseko==1

replace worksector=2 if wseko==2

replace worksector=3 if wseko==3

* generation of tertiary education dummy (0 = below tertiary education; 1 = tertiary education)
gen tertedu=0
replace tertedu=1 if if (habgh==3|habgh==4)

*generation of self-employment dummy (0 = non self-employed; 1 = self-employed)
gen self_employed=0

replace self_employed=1 if sthb==1|sthb==2

*generation of religion dummies (see the generation of labels below for the definition of religion categories)
gen religion=1 if rel==120|rel==130
replace religion=2 if rel==111|rel==112|rel==113|rel==115
replace religion=3 if rel==300
replace religion=4 if rel==114
replace religion=5 if rel==200
replace religion=6 if rel==140
replace religion=7 if rel==150
replace religion=8 if rel==400
replace religion=9 if rel==500

label define religionlabel 1 "Catholic" 2 "Protestant" 3 "Muslim" 4 "Jeovah" 5 "Jew" 6 "Orthodox" 7 "Other Christians" 8 "Other religions" 9 "Atheist"

label values religion religionlabel 

** generation of the immigration status categoric variable "imm" (0 = swiss native; 1 = first gen. immigrant; 2 = second gen. imm.)

* identification of Swiss natives (imm=0)
gen double imm=0

* identification of first generation immigrants as the individuals who are born abroad (imm = 1)
replace imm=1 if gort>=8204

*identification of fathers as the male-gendered individuals who live in a household with children and being either the household head or the partner of the household head (0 = not father in the household; 1 = father in the household)
gen double father=0

replace father=1 if (female==0 & hhtp>=2211 & hhtp<=2320 & (rphh==1|rphh==2))

*identification of mothers as the female-gendered individuals who live in a household with children and being either the household head or the partner of the household head (0 = not mother in the household; 1 = mother in the household)
gen double mother=0

replace mother=1 if (female==1 & hhtp>=2211 & hhtp<=2320 & (rphh==1|rphh==2))

*identification of first-gen. imm. fathers as the first gen. imm. male-gendered individuals who live in a household with children and being either the household head or the partner of the household head (0 = not father in the household; 1 = father in the household)
gen double imm_father=0

replace imm_father=1 if (female==0 & imm==1 & hhtp>=2211 & hhtp<=2320 & (rphh==1|rphh==2))

*identification of first-gen. imm. mothers as the first-gen. imm. female-gendered individuals who live in a household with children and being either the household head or the partner of the household head (0 = not mother in the household; 1 = mother in the household)
gen double imm_mother=0

replace imm_mother=1 if (female==1 & imm==1 & hhtp>=2211 & hhtp<=2320 & (rphh==1|rphh==2))

sort hhnr

* identification of immigrant households (0 = no first-gen. imm. parent; 1 = one of the parents is a first-gen. imm.; 2 = both parents are first-gen. imm.)
by hhnr: egen imm_householdfath=sum(imm_father)

by hhnr: egen imm_householdmoth=sum(imm_mother)

gen imm_household= imm_householdfath + imm_householdmoth

* indentification of second generation immigrants (imm=2) as those born in Switzerland and living in a household with both parents who are first-gen. immigrants
replace imm=2 if ((gort<8204 & gort!=0 & imm_household==2 & sthh==2)| (gort<8204 & gort!=0 & imm_household==1 & sthh==2 & (hhtp==2310|hhtp==2320))|(gort<8204 & gort!=0 & hmat==2))

* generation of swiss native dummy (if variable imm = 0)
gen double native=0 

replace native=1 if imm==0

* generation of first-generation immigrants dummy (if variable imm = 1)
gen double firstg_imm=0

replace firstg_imm=1 if imm==1

* generation of second-generation immigrants dummy (if variable imm = 2)
gen double secg_imm=0

replace secg_imm=1 if imm==2

* generation of immigrants dummy (if variable imm = 1 or imm = 2)
gen immigrant=0

replace immigrant=1 if (firstg_imm==1|secg_imm==1)

* generation of Swiss nationality dummy (0 = foreing nationality; 1 = swiss nationality)
gen double swissnational=0

replace swissnational=1 if hmat==1

* generation of dummy indicating whether the individual has lived in Switzerland for more than 5 years (0 = more than 5 years ; 1 = less than 5 years)
gen double years5abroad=0

replace years5abroad=1 if wor5>=8204

replace years5abroad=0 if native==1|secg_imm==1

* generation of child dummy 
gen double child=0

replace child=1 if sthh==2

* generation of variable for number of children in the household
sort hhnr

by hhnr: egen household_nchild=sum(child)

gen hh_child=0 if household_nchild==0

replace hh_child=1 if household_nchild>0

* generation of marriage status dummy (0 = not married; 1 = married) 
gen double married=0

replace married=1 if zivl>1

* generation of dummies identifying Swiss native by spoken language
foreach i in German French Italian Romansh{

gen `i'_native=0

replace `i'_native=1 if spklang=="`i'" & native==1
}

* generation of dummy identifying speakers of one of Swiss native languages
gen natspk=0 

replace natspk=1 if spklang=="German"|spklang=="French"|spklang=="Italian"|spklang=="Romansh"

* generation of dummy identifying first-gen. imm. speaking of one of Swiss native languages
gen natspk_imm=0 if firstg_imm==1
replace natspk_imm=1 if firstg_imm==1 & (spklang=="German"|spklang=="French"|spklang=="Italian"|spklang=="Romansh")

* generation of dummy identifying second-gen. imm. speaking of one of Swiss native languages
gen natspk_secgimm=0 if secg_imm==1
replace natspk_secgimm=1 if secg_imm==1 & (spklang=="German"|spklang=="French"|spklang=="Italian"|spklang=="Romansh")

* generation of continent of birth dummies
gen continent=1 if gort>=8204 & gort<=8290

replace continent=2 if gort>=8304 & gort<=8390

replace continent=3 if (gort==8423|gort==8439)

replace continent=4 if (gort==8407|gort==8490)

replace continent=5 if gort>=8508 & gort<=8590

replace continent=6 if gort==8690

gen continent_nat=1 if nati>=8204 & nati<=8290

replace continent_nat=2 if nati>=8304 & nati<=8390

replace continent_nat=3 if (nati==8423|nati==8439)

replace continent_nat=4 if (nati==8407|nati==8490)

replace continent_nat=5 if nati>=8508 & nati<=8590

replace continent_nat=6 if nati==8690

* generation of elementary occupations dummy (0 = rest of occupations; 1 = elementary occupations)
gen lowsk_occ=0

replace lowsk_occ=1 if (isco>=5000 & isco<=5220)|(isco>=9000 & isco<=9330)

* recode from prediction future reference (Chen, 2013) to weak future reference - it's just a differet way to label future reference
gen weak_ftr=0 if prediction_ftr==1
replace weak_ftr=1 if prediction_ftr==0

*gen variable indicating area of birth
gen aor1=gort if firstg_imm==1
replace aor1=nati if secg_imm==1
replace aor1=district_gort if native==1

* generation of dummy identifying individuals living in multilingual cantons
gen multil_kant=0
replace multil_kant=1 if kant==2|kant==10|kant==18|kant==23

* generation of dummy identifying individuals living in multilingual cantons (Grabunden excluded)
gen multil_kant_nograb=0
replace multil_kant_nograb=1 if kant==2|kant==10|kant==23

* drop unnecessary variables
drop zjhr fbnr zgdo ams sgde wo5k gortk hmat aort sort zivl rel rphh sthh hhtp aper kams erlb pber sthb pens wart wseko refo sopk awegz awegh avemi swegz swegh svemi habgh habag habgb habgn rart zkrs1 mua name_mua BEZIRK KT area _merge

replace weak_ftr=0 if spklang=="Yugoslavian"
replace weak_ftr=1 if spklang=="Danish"

/// if you want to get statistics on linguistic majorities and export to a separate dataset, execute the do-file below (used for Qgis analysis)
*preserve
* do "`user'\do files paper language dropbox\language majorities zgde dis.do"
*restore
/// merge with dataset of linguistic majorities in municipality of birth (gort)

* Merging with datasets created on Qgis to identify those administrative units at linsuistic border or their distance from bordering countries
merge m:1 district using "$dataset\districts at linguistic border 60tr multiling cantons.dta", nogenerate
merge m:1 zgde using "$dataset\municipalities at linguistic border 60tr multiling cantons.dta", nogenerate
merge m:1 zgde using "$dataset\municipalities at linguistic border 50tr multiling cantons.dta", nogenerate

* Merging with WALS dataset on language features
merge m:1 spklang using "$dataset\language features.dta", gen(merge_feat)

drop if missing(spklang)

* generate new dataset with the new variables that have been created
save "$output\temp.dta", replace			  

* Generation of variable indicating the linguistic majority by municipality
bys zgde: egen natpop_zgde=total(native==1) 
bys zgde: egen germspk_natpop_zgde=total(native==1 & spklang=="German") 
bys zgde: egen frenspk_natpop_zgde=total(native==1 & spklang=="French") 
bys zgde: egen italspk_natpop_zgde=total(native==1 & spklang=="Italian") 
bys zgde: egen romaspk_natpop_zgde=total(native==1 & spklang=="Romansh") 

foreach i in germ fren ital roma{
gen sh_`i'spk_natpop_zgde=`i'spk_natpop_zgde/natpop_zgde
}

gen majspklang_nat_zgde=1 if germspk_natpop_zgde>frenspk_natpop_zgde & germspk_natpop_zgde>italspk_natpop_zgde & germspk_natpop_zgde>romaspk_natpop_zgde
replace majspklang_nat_zgde=2 if frenspk_natpop_zgde>germspk_natpop_zgde & frenspk_natpop_zgde>italspk_natpop_zgde & frenspk_natpop_zgde>romaspk_natpop_zgde
replace majspklang_nat_zgde=3 if italspk_natpop_zgde>germspk_natpop_zgde & italspk_natpop_zgde>frenspk_natpop_zgde & italspk_natpop_zgde>romaspk_natpop_zgde
replace majspklang_nat_zgde=4 if romaspk_natpop_zgde>germspk_natpop_zgde & romaspk_natpop_zgde>frenspk_natpop_zgde & romaspk_natpop_zgde>italspk_natpop_zgde

* keep first generation immigrants
keep if firstg_imm==1

replace lowsk_occ = . if isco==9999

* generation of language stayers and switchers dummies
gen switcher = natspk == 1
gen stayer = switcher == 0

* definition of Swiss lingustic areas categorical variable
gen germanarea = (kant!=21 & kant!=18 & kant!=10 & (kant<22 | kant>26))
gen frencharea = (kant==26 | kant==24 | kant==22 | kant==23 | kant==25 | kant== 10)
gen italianarea = (kant==21 | kant==18)

* generation of variable indicating modal language by country (only among language stayers)
bysort aor1 switcher: egen modal_lang = mode(spklang), maxmode

* remove linguistic outliers (i.e., if language stayers but not speaking the modal language in the country)
drop if spklang != modal_lang & switcher == 0 

label var self_employed "Self empl."
label var weak_ftr "Weak FTR"
label var switcher "Switcher"
label var stayer "Stayer"
label var altj "Age"
label var household_nchild "# childs"
label var tertedu "High skilled"
label var years5abroad "Less than 5 years in SWZ"
label var swissnational "Citizen"
label define ftr 0 "strong-FTR" 1 "weak-FTR"
label values weak_ftr ftr
  
* keep if age between 25 and 70 years old
keep if altj>=25 & altj<=70	

* generation of std-errors cluster variable (i.e., country of birth by Swiss linguistic areas)
egen aor1_maj=group(aor1 majspklang_nat_zgde)

* drop speakers of Yugoslavian and Danish language (because WALS linguistic features are not available)
drop if spklang=="Yugoslavian"|spklang=="Danish"
drop if gort==8290 /* Drop observations from European country of birth without further indication */
drop if aor1 == 8999 /* Drop observations from foreign country of birth without further indication */
* drop observations from countries where one of Swiss languages is an official language (for example, Germany, France, etc. - see in the main text for the complete list)
drop if aor1==8218|aor1==8222 | aor1==8229 | aor1==8207|aor1==8212 | aor1==8204 | aor1==8304 | aor1==8357 | aor1==8423
* drop observations living in Switzerland for less than 5 years
drop if years5abroad == 1

gen other_africa = aor1== 8390
gen other_america = aor1== 8490
gen other_asia = aor1== 8590
gen oceania = aor1== 8690

* generation of interaction between weak_FTR and switcher indicator
gen weak_FTR_switcher = weak_ftr == 1 & switcher ==1
label var weak_FTR_switcher "Weak FTR $ \times $ Switcher"

* We here remove 38 more linguistic outliers. These are 33 individuals born in Poland, and 5 born in Cambodia, who speak English (Their inclusion does not alter the results)
drop if switcher == 0 & (aor1 == 8230 | aor1 == 8518)

* save new dataset with the new variables that have been created containing first generation immigrants only
save "$output\temp_firstgen.dta", replace			  

global sdcluster = "aor1_maj"

use "$output\temp_firstgen.dta", clear
 
**********************
* Summary Statistics *
**********************

preserve
keep if weak_ftr!=.

reghdfe self_employed weak_ftr switcher $contr if employed==1, absorb(district aor1) vce(cluster $sdcluster)
keep if e(sample)==1

gen constant = "Total"

label define t 1 "Total"
gen constant2 = 1
label values constant2 t


* Table 1 - The sample
encode spklang, gen(LLL)

* Generation of descriptive statistics of languages in the sample across type of future reference (weak vs strong ftr)
bysort weak_ftr : tab spklang self_employed
tabout spklang if weak_ftr==0 using "$output\tab1A.tex", replace ///
		c(count LLL mean self_employed) f(0c 2c) h1(nil) h2(nil) h3(nil) ptotal(none) style(tex) lines(none) sum
tabout spklang if weak_ftr==1 using "$output\tab1B.tex", replace ///
		c(count LLL mean self_employed) f(0c 2c) h1(nil) h2(nil) h3(nil) ptotal(none) style(tex) lines(none) sum
tabout constant2 using "$output\tab1C.tex", replace ///
        c(count constant2 mean self_employed) f(0c 2c) h1(nil) h2(nil) h3(nil) ptotal(none) style(tex) lines(none) sum 		
			 		
* Table 2 - Summary statistics
* Generation of descriptive statistics of outcome and control variables across type of future reference (weak vs strong ftr)

tab religion, gen(R)

tabout weak_ftr using "$output\tab2A.tex", replace ///
c(mean self_employed mean female mean altj  mean tertedu mean swissnational) ///
  f(2c) sum h1(nil) h2(nil) h3(nil) style(tex) lines(none)			

tabout weak_ftr using "$output\tab2B.tex", replace ///
c(mean married mean household_nchild  ///
  mean R1 mean R2 mean R9) f(2c) sum h1(nil) h2(nil) h3(nil) style(tex) lines(none)			

restore

/// Estimates on first generation immigrants

************
* Analysis *
************

use "$output\temp_firstgen.dta", clear
 
global indcontr = "female altj altj2 i.religion swissnational married household_nchild tertedu"
global langcontr = "gend_dist polit_dist past_tense perfect_tense"
global gps_se "patience risktaking posrecip negrecip altruism trust self_emp_cb" 
global sdcluster = "aor1_maj"

*** Table 3 - Baseline estimates on subsamples of stayers and switchers, plus pooled sample with interaction between FTR and switcher status dummy

preserve 
use "$dataset\GPS_Dataset\GPS_dataset_country_level\country_gort.dta", clear

foreach var in patience risktaking posrecip negrecip altruism trust{
sum `var'
local m_`var' = r(mean)
}
restore

preserve 
use "$dataset\self employed in country of birth_wb.dta", clear
sum self_emp_cb
local m_self_emp_cb = r(mean)
restore

* Merging with country-of-birth-level GPS variables
merge m:1 gort using "$dataset\GPS_Dataset\GPS_dataset_country_level\country_gort.dta", gen(merge_gps)

foreach var in patience risktaking posrecip negrecip altruism trust{
replace `var' = `m_`var'' if merge_gps==1
}

* Merging with country-of-birth-level self-employment (World Bank data)
merge m:1 gort using "$dataset\self employed in country of birth_wb.dta", gen(merge_se)

replace self_emp_cb = `m_self_emp_cb' if merge_se==1

*** Table 3, column 1 - stayers only - GPS controls and no country of origin fixed effects
global contr = "$indcontr $langcontr $gps_se"

preserve 
keep if stayer == 1 
reghdfe self_employed weak_ftr $contr other_africa other_america other_asia oceania if (altj>=25 & employed==1  ), absorb(district) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\baseline", nocons keep(weak_ftr) ctitle("Stayers") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, GPS cult. dimensions, YES, Self-empl. in birth-country, YES, District FE, YES) tex(frag) excel replace nonotes
restore

*** Table 3, column 2 - switchers only - GPS controls and no country of origin fixed effects
global contr = "$indcontr $gps_se"

preserve 
keep if switcher == 1
reghdfe self_employed weak_ftr $contr other_africa other_america other_asia oceania if (altj>=25 & employed==1  ), absorb(district) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\baseline", nocons keep(weak_ftr*) ctitle("Switchers") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, GPS cult. dimensions, YES, Self-empl. in birth-country, YES, District FE, YES) tex(frag) excel append nonotes

*** Table 3, column 3 - switchers only with country of origin fixed effects
global contr = "$indcontr"

reghdfe self_employed weak_ftr $contr if (altj>=25 & employed==1  ), absorb(district aor1) vce(cluster $sdcluster)
outreg2 using "$output\baseline", nocons keep(weak_ftr*) ctitle("Switchers") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Country of origin FE, YES, District FE, YES) tex(frag) excel append nonotes
restore

*** Table 3, column 4 - pooled sample - GPS controls and no country of origin fixed effects
global contr = "$indcontr $langcontr $gps_se"

reghdfe self_employed weak_ftr switcher weak_FTR_switcher $contr if (altj>=25 & employed==1  ), absorb(district) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\baseline", nocons keep(weak_ftr* switcher weak_FTR_switcher) ctitle("Pooled") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, GPS cult. dimensions, YES, Self-empl. in birth-country, YES, District FE, YES) tex(frag) excel append nonotes

*** Table 3, column 5 - pooled sample - country of origin fixed effects
global contr = "$indcontr $langcontr"

reghdfe self_employed weak_ftr switcher weak_FTR_switcher $contr if (altj>=25 & employed==1  ), absorb(district aor1) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\baseline", nocons keep(weak_ftr* switcher weak_FTR_switcher) ctitle("Pooled") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, Country of origin FE, YES, District FE, YES) tex(frag) excel append nonotes

*** Table 4 - estimates on multilingual cantons

*** Table 4, column 1 - baseline estimates on pooled sample from the whole Switzerland (column 5, Table 3)
global contr = "$indcontr  $langcontr"
reghdfe self_employed weak_ftr switcher weak_FTR_switcher $contr if (altj>=25 & employed==1  ), absorb(district aor1) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\multilingual_cantons", nocons keep(weak_ftr* switcher weak_FTR_switcher) ctitle("Baseline") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, District FE, YES, Country of origin FE, YES) tex(frag) excel replace nonotes

*** Table 4, column 2 - pooled sample from multilingual cantons (Grabunded excluded)
reghdfe self_employed weak_ftr switcher weak_FTR_switcher $contr if (altj>=25 & employed==1 & multil_kant_nograb==1), absorb(district aor1) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\multilingual_cantons", nocons keep(weak_ftr* switcher weak_FTR_switcher) ctitle("Multilingual cantons") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, District FE, YES, Country of origin FE, YES) tex(frag) excel append nonotes

*** Table 4, column 2 - pooled sample from districts at the linguistic border in multilingual cantons (Grabunded excluded)
reghdfe self_employed weak_ftr switcher weak_FTR_switcher $contr if (altj>=25 & employed==1 & multil_kant_nograb==1 & ling_border_dis60tr==1), absorb(district aor1) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\multilingual_cantons", nocons keep(weak_ftr* switcher weak_FTR_switcher) ctitle("Linguistic Border") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, District FE, YES, Country of origin FE, YES) tex(frag) excel append nonotes

*** Table 5 - estimates excluding low-skilled occupations, excluding agricultural sector and by education - pooled sample
global contr = "$indcontr  $langcontr"

*** Table 5, column 1 - estimates excluding low skill occupations
reghdfe self_employed weak_ftr switcher weak_FTR_switcher $contr if (lowsk_occ==0 & altj>=25 & employed==1  ), absorb(district aor1) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\skills", nocons keep(weak_ftr switcher weak_FTR_switcher) ctitle("Low-skilled occupations excluded") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, District FE, YES, Country of origin FE, YES) tex(frag) excel replace nonotes

*** Table 5, column 2 - estimates excluding agriculture
gen worksector2 = worksector
replace worksector2 = 1 if worksector!=. & ((isco>=6000 & isco<7000) | (isco>=9200 & isco<9300))
replace worksector2 = 3 if worksector!=. & ((isco>=5000 & isco<6000) | (isco>=4000 & isco<5000) | (isco>=8300 & isco<=8400) | (isco>=9100 & isco<9200) | (isco>=9400 & isco<9700))
replace worksector2 = 2 if worksector!=. & ((isco>=7000 & isco<8300) | (isco>=9300 & isco<9400)) 

gen worksector3 = worksector
replace worksector3 = . if isco==9999

gen worksector4 = 1 if worksector== 1 |  ((isco>=6000 & isco<7000) | (isco>=9200 & isco<9300))
replace worksector4 = 23 if (worksector==2 | worksector==3) & !((isco>=6000 & isco<7000) | (isco>=9200 & isco<9300))
replace worksector4 = 23 if (worksector==2 | worksector==3) & (((isco>=5000 & isco<6000) | (isco>=4000 & isco<5000) | (isco>=8300 & isco<=8400) | (isco>=9100 & isco<9200) | (isco>=9400 & isco<9700)))
replace worksector4 = 23 if (worksector==2 | worksector==3) & ((isco>=7000 & isco<8300) | (isco>=9300 & isco<9400)) 

reghdfe self_employed weak_ftr switcher weak_FTR_switcher $contr if (worksector4==23 & altj>=25 & employed==1  ), absorb(district aor1) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\skills", nocons keep(weak_ftr switcher weak_FTR_switcher) ctitle("Agriculture excluded") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, District FE, YES, Country of origin FE, YES) tex(frag) excel append nonotes

*** Table 5, column 3 and 4 - estimates by level of education (non tertiary vs tertiary education)
reghdfe self_employed weak_ftr switcher weak_FTR_switcher $contr if (tertedu==0 & altj>=25 & employed==1  ), absorb(district aor1) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\skills", nocons keep(weak_ftr switcher weak_FTR_switcher) ctitle("Secondary education or less") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, District FE, YES, Country of origin FE, YES) tex(frag) excel append nonotes

reghdfe self_employed weak_ftr switcher weak_FTR_switcher $contr if (tertedu==1 & altj>=25 & employed==1  ), absorb(district aor1) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\skills", nocons keep(weak_ftr switcher weak_FTR_switcher) ctitle("Tertiary education") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, District FE, YES, Country of origin FE, YES) tex(frag) excel append nonotes

*** Table 6 - estimates by gender and age - pooled sample

global contr "$indcontr $langcontr"

reghdfe self_employed weak_ftr switcher weak_FTR_switcher $contr if (female==0 & altj>=25 & employed==1  ), absorb(district aor1) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\agegender", nocons keep(weak_ftr switcher weak_FTR_switcher) ctitle("Males") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, District FE, YES, Country of origin FE, YES) tex(frag) excel replace nonotes

reghdfe self_employed weak_ftr switcher weak_FTR_switcher $contr if (female==1 & employed==1 ), absorb(district aor1) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\agegender", nocons keep(weak_ftr switcher weak_FTR_switcher) ctitle("Females") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, District FE, YES, Country of origin FE, YES) tex(frag) excel append nonotes

reghdfe self_employed weak_ftr switcher weak_FTR_switcher $contr if (altj>=25 & altj<36 & employed==1 ), absorb(district aor1) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\agegender", nocons keep(weak_ftr switcher weak_FTR_switcher) ctitle("Age 25-35") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, District FE, YES, Country of origin FE, YES) tex(frag) excel append nonotes

reghdfe self_employed weak_ftr switcher weak_FTR_switcher $contr if (altj>=36 & employed==1 ), absorb(district aor1) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\agegender", nocons keep(weak_ftr switcher weak_FTR_switcher) ctitle("Age over 35") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, District FE, YES, Country of origin FE, YES) tex(frag) excel append nonotes


*** Appendix Tables ***

***  Table A3 - Baseline estimates with non inflectional future dummy rather than weak ftr dummy
use "$output\temp_firstgen.dta", clear
 
global indcontr = "female altj altj2 i.religion swissnational married household_nchild tertedu"
global langcontr = "gend_dist polit_dist past_tense perfect_tense"
global gps_se "patience risktaking posrecip negrecip altruism trust self_emp_cb" 
egen aor1_maj_spklang = group(aor1_maj spklang)
global sdcluster = "aor1_maj_spklang"

***  Baseline estimates with non inflectional future dummy rather than weak ftr dummy

preserve 
use "$dataset\GPS_Dataset\GPS_dataset_country_level\country_gort.dta", clear

foreach var in patience risktaking posrecip negrecip altruism trust{
sum `var'
local m_`var' = r(mean)
}
restore

preserve 
use "$dataset\self employed in country of birth_wb.dta", clear
sum self_emp_cb
local m_self_emp_cb = r(mean)
restore

merge m:1 gort using "$dataset\GPS_Dataset\GPS_dataset_country_level\country_gort.dta", gen(merge_gps)

foreach var in patience risktaking posrecip negrecip altruism trust{
replace `var' = `m_`var'' if merge_gps==1
}

merge m:1 gort using "$dataset\self employed in country of birth_wb.dta", gen(merge_se)

replace self_emp_cb = `m_self_emp_cb' if merge_se==1

gen non_inflectional = inflectional_ftr == 0
replace non_inflectional = 1 if spklang == "Portuguese"
label var non_inflectional "Non inflectional future"

gen non_infl_switcher = non_inflectional == 1 & switcher ==1
label var non_infl_switcher "Non inflectional $ \times $ Switcher"

*** Table 3, column 1 - stayers only - GPS controls and no country of origin fixed effects
global contr = "$indcontr $langcontr $gps_se"

preserve 
keep if stayer == 1
reghdfe self_employed non_inflectional $contr other_africa other_america other_asia oceania if (altj>=25 & employed==1  ), absorb(district) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\baseline_non_inflectional_new", nocons keep(non_inflectional) ctitle("Stayers") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, GPS cult. dimensions, YES, Self-empl. in birth-country, YES, District FE, YES) tex(frag) excel replace nonotes
restore

*** Table 3, column 2 - switchers only - GPS controls and no country of origin fixed effects
global contr = "$indcontr $gps_se"

preserve 
keep if switcher == 1
reghdfe self_employed non_inflectional $contr other_africa other_america other_asia oceania if (altj>=25 & employed==1  ), absorb(district) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\baseline_non_inflectional_new", nocons keep(non_inflectional*) ctitle("Switchers") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, GPS cult. dimensions, YES, Self-empl. in birth-country, YES, District FE, YES) tex(frag) excel append nonotes

*** Table 3, column 3 - switchers only with country of origin fixed effects
global contr = "$indcontr"

reghdfe self_employed non_inflectional $contr if (altj>=25 & employed==1  ), absorb(district aor1) vce(cluster $sdcluster)
outreg2 using "$output\baseline_non_inflectional_new", nocons keep(non_inflectional*) ctitle("Switchers") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Country of origin FE, YES, District FE, YES) tex(frag) excel append nonotes
restore

*** Table 3, column 4 - pooled sample - GPS controls and no country of origin fixed effects
global contr = "$indcontr $langcontr $gps_se"

reghdfe self_employed non_inflectional switcher non_infl_switcher $contr if (altj>=25 & employed==1  ), absorb(district) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\baseline_non_inflectional_new", nocons keep(non_inflectional* switcher non_infl_switcher) ctitle("Pooled") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, GPS cult. dimensions, YES, Self-empl. in birth-country, YES, District FE, YES) tex(frag) excel append nonotes

*** Table 3, column 5 - pooled sample - country of origin fixed effects
global contr = "$indcontr $langcontr"

reghdfe self_employed non_inflectional switcher non_infl_switcher $contr if (altj>=25 & employed==1  ), absorb(district aor1) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\baseline_non_inflectional_new", nocons keep(non_inflectional* switcher non_infl_switcher) ctitle("Pooled") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, Country of origin FE, YES, District FE, YES) tex(frag) excel append nonotes

*** Table A4 - descriptive statistics by country of origin
use "$output\temp_firstgen.dta", clear

gen weakftraor = 0
replace weakftraor = 1 if aor1 == 8206
replace weakftraor = 1 if aor1 == 8211
replace weakftraor = 1 if aor1 == 8227
replace weakftraor = 1 if aor1 == 8234
replace weakftraor = 1 if aor1 == 8508
replace weakftraor = 1 if aor1 == 8515
replace weakftraor = . if aor1 == 8390|aor1 == 8490|aor1 == 8590
label define weakftraor_l 0 "Strong" 1 "Weak"
label values weakftraor weakftraor_l  

gen switcher_weakftr = switcher == 1 & weak_ftr == 1
gen switcher_strongftr = switcher == 1 & weak_ftr == 0

label define coo 8204 "Belgium" 8206 "Denmark" 8207 "Germany" 8211 "Finland" 8212 "France" 8214 "Greece" 8215 "UK" 8218 "Italy" 8220 "Former Yugoslavia" 8222 "Liechtenstein" 8227 "Netherlands" 8229 "Austria" 8230 "Poland" 8231 "Portugal" 8232 "Romania" 8234 "Sweden" 8236 "Spain" 8238 "former Czechoslovakia" 8239 "Turkey" 8240 "Hungary" 8290 "Other European" 8304 "Algeria" 8357 "Tunisia" 8390 "Other Africa" 8407 "Chile" 8423 "Canada" 8439 "United States" 8490 "Other America" 8508 "China" 8510 "India" 8513 "Iran" 8514 "Israel" 8515 "Japan" 8518 "Cambodia" 8523 "Lebanon" 8545 "Vietnam" 8590 "Other Asia" 8690 "Oceania"
label values gort coo	  

gen cb_name="Belgium" if gort==8204
replace cb_name="Denmark" if gort==8206
replace cb_name="Germany" if gort==8207
replace cb_name="Finland" if gort==8211
replace cb_name="France" if gort==8212
replace cb_name="Greece" if gort==8214
replace cb_name="United Kingdom" if gort==8215
replace cb_name="Italy" if gort==8218
replace cb_name="Former Yugoslavia" if gort==8220
replace cb_name="Liechtenstein" if gort==8222
replace cb_name="Netherlands" if gort==8227
replace cb_name="Austria" if gort==8229
replace cb_name="Poland" if gort==8230
replace cb_name="Portugal" if gort==8231
replace cb_name="Romania" if gort==8232
replace cb_name="Sweden" if gort==8234
replace cb_name="Spain" if gort==8236
replace cb_name="former Czechoslovakia" if gort==8238
replace cb_name="Turkey" if gort==8239
replace cb_name="Hungary" if gort==8240
replace cb_name="Algeria" if gort==8304
replace cb_name="Tunisia" if gort==8357
replace cb_name="Other Africa" if gort==8390
replace cb_name="Chile" if gort==8407
replace cb_name="Canada" if gort==8423
replace cb_name="United States" if gort==8439
replace cb_name="Other America" if gort==8490
replace cb_name="China" if gort==8508
replace cb_name="India" if gort==8510
replace cb_name="Iran" if gort==8513
replace cb_name="Israel" if gort==8514
replace cb_name="Japan" if gort==8515
replace cb_name="Cambodia" if gort==8518
replace cb_name="Lebanon" if gort==8523
replace cb_name="Vietnam" if gort==8545
replace cb_name="Other Asia" if gort==8590
replace cb_name="Oceania" if gort==8690

gen lowsk_occ_se=0 if lowsk_occ==1
replace lowsk_occ_se=1 if lowsk_occ==1 & self_employed==1

gen higsk_occ_se=0 if lowsk_occ==0
replace higsk_occ_se=1 if lowsk_occ==0 & self_employed==1

keep if firstg_imm==1 & female!=. & weak_ftr!=. & switcher!=. & altj!=. & altj2!=. & religion!=. & years5abroad!=. & swissnational!=. & married!=. & household_nchild!=. & tertedu!=. & gend_dist!=. & polit_dist!=. & past_tense!=. & perfect_tense!=. & altj>=25 & employed==1   & district!=.

tabout cb_name using "$output\tabApp_stat_by_country.tex", replace ///
c(count gort mean weakftraor mean switcher_weakftr mean switcher_strongftr mean tertedu mean lowsk_occ mean self_employed mean lowsk_occ_se mean higsk_occ_se ) f(0c 2c 2c) sum h1(nil) h2(nil) h3(nil) style(tex) lines(none)

*** Table A5 and A6 - estimates of the country-level correlation between GPS variables (Table A5) and Hofstede's dimensions (Table A6) with Weak FTR of the official language

use "$dataset\hofstede cultural dimensions and language dataset.dta", clear
gen isocode=country_code
replace isocode = ctr if missing(country_code)
merge m:1 isocode using "$dataset\GPS_Dataset\GPS_dataset_country_level\country.dta", generate(_merge1)

keep if _merge1==3

gen weak_ftr = 0 if prediction_ftr == 1
replace weak_ftr = 1 if prediction_ftr == 0
label var weak_ftr "Weak FTR"

local geocontr pdiv_aa abslat suitavg elevavg arable distcr temp precip i.legor i.oldw
local GPS patience risktaking posrecip negrecip altruism trust
local hofstede  ltowvs uai idv pdi mas ivr
local append replace

label var pdi "Power distance"
label var idv "Individualism"
label var mas "Masculinity"
label var uai "Uncertainty avoidance"
label var ltowvs "Long-term orientation"
label var ivr "Indulgence vs restraint"

foreach var in `GPS'{
	
reg weak_ftr `var' `geocontr'  i.continent_n, robust
outreg2 using "$output\GPS_weakFTR_country_level", nocons keep(`var') tex(pretty landscape) excel label  ctitle("Weak FTR") addtext(Continent FE, YES, Geograph. and Instit. controls, YES) `append'
local append append

}

reg weak_ftr `GPS' `geocontr'  i.continent_n, robust
outreg2 using "$output\GPS_weakFTR_country_level", nocons keep(`GPS') tex(pretty landscape) excel label  ctitle("Weak FTR") addtext(Continent FE, YES, Geograph. and Instit. controls, YES) append

local append replace

foreach var in `hofstede'{
	
reg weak_ftr `var' `geocontr'  i.continent_n, robust
outreg2 using "$output\hofstede_weakFTR_country_level", nocons keep(`var') tex(pretty landscape) excel label  ctitle("Weak FTR") addtext(Continent FE, YES, Geograph. and Instit. controls, YES) `append'
local append append

}

reg weak_ftr `hofstede' `geocontr'  i.continent_n, robust
outreg2 using "$output\hofstede_weakFTR_country_level", nocons keep(`hofstede') tex(pretty landscape) excel label  ctitle("Weak FTR") addtext(Continent FE, YES, Geograph. and Instit. controls, YES) append

*** Table A7 - Baseline estimates with Hofstede's cultural dimensions (rather than GPS) on subsamples of stayers and switchers, plus pooled sample with interaction between FTR and switcher status dummy

use "$output\temp_firstgen.dta", clear
 
global indcontr = "female altj altj2 i.religion swissnational married household_nchild tertedu"
global langcontr = "gend_dist polit_dist past_tense perfect_tense"
global gps_se "patience risktaking posrecip negrecip altruism trust self_emp_cb" 
egen aor1_maj_spklang = group(aor1_maj spklang)
global sdcluster = "aor1_maj_spklang"


use "$output\temp_firstgen.dta", clear

preserve 
use "$dataset\hofstede cultural dimensions by country of birth.dta", clear

foreach var in pdi idv mas uai ltowvs ivr{
sum `var'
local m_`var' = r(mean)
}
restore

preserve 
use "$dataset\self employed in country of birth_wb.dta", clear
sum self_emp_cb
local m_self_emp_cb = r(mean)
restore

merge m:1 gort using "$dataset\hofstede cultural dimensions by country of birth.dta", gen(merge_hof)

foreach var in pdi idv mas uai ltowvs ivr{
replace `var' = `m_`var'' if merge_hof==1
}

merge m:1 gort using "$dataset\self employed in country of birth_wb.dta", gen(merge_se)

replace self_emp_cb = `m_self_emp_cb' if merge_se==1

global indcontr = "female altj altj2 i.religion swissnational married household_nchild tertedu"
global langcontr = "gend_dist polit_dist past_tense perfect_tense"
global hof_se "pdi idv mas uai ltowvs ivr self_emp_cb" 
global sdcluster = "aor1_maj"

*** Table A7, column 1 - stayers only - Hofstede's controls and no country of origin fixed effects
global contr = "$indcontr $langcontr $hof_se"

preserve 
keep if stayer == 1
reghdfe self_employed weak_ftr $contr other_africa other_america other_asia oceania if (altj>=25 & employed==1  ), absorb(district) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\baseline_hofstede", nocons keep(weak_ftr) ctitle("Stayers") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, Hofstede's cult. dimensions, YES, Self-empl. in birth-country, YES, District FE, YES) tex(frag) excel replace nonotes
restore

*** Table A7, column 2 - switchers only - Hofstede's controls and no country of origin fixed effects
global contr = "$indcontr $hof_se"

preserve 
keep if switcher == 1
reghdfe self_employed weak_ftr $contr other_africa other_america other_asia oceania if (altj>=25 & employed==1  ), absorb(district) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\baseline_hofstede", nocons keep(weak_ftr*) ctitle("Switchers") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Hofstede's cult. dimensions, YES, Self-empl. in birth-country, YES, District FE, YES) tex(frag) excel append nonotes

*** Table A7, column 3 - switchers only with country of origin fixed effects
global contr = "$indcontr"

reghdfe self_employed weak_ftr $contr if (altj>=25 & employed==1  ), absorb(district aor1) vce(cluster $sdcluster)
outreg2 using "$output\baseline_hofstede", nocons keep(weak_ftr*) ctitle("Switchers") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Country of origin FE, YES, District FE, YES) tex(frag) excel append nonotes
restore

*** Table A7, column 4 - pooled sample - Hofstede's controls and no country of origin fixed effects
global contr = "$indcontr $langcontr $hof_se"

reghdfe self_employed weak_ftr switcher weak_FTR_switcher $contr if (altj>=25 & employed==1  ), absorb(district) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\baseline_hofstede", nocons keep(weak_ftr* switcher weak_FTR_switcher) ctitle("Pooled") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, Hofstede's cult. dimensions, YES, Self-empl. in birth-country, YES, District FE, YES) tex(frag) excel append nonotes

*** Table A7, column 5 - pooled sample - country of origin fixed effects
global contr = "$indcontr $langcontr"

reghdfe self_employed weak_ftr switcher weak_FTR_switcher $contr if (altj>=25 & employed==1  ), absorb(district aor1) vce(cluster $sdcluster)
sum self_employed if e(sample)==1
local self_employed = string(r(mean), "%9.2f")
outreg2 using "$output\baseline_hofstede", nocons keep(weak_ftr* switcher weak_FTR_switcher) ctitle("Pooled") label addtext(Mean dep. var., `self_employed' , Individual controls, YES, Religion dummies, YES, Linguistic features, YES, Country of origin FE, YES, District FE, YES) tex(frag) excel append nonotes

*** Table A8 - estimates on the population of Swiss natives

use "$output\temp.dta", clear

bys zgde: egen natpop_zgde=total(native==1) 
bys zgde: egen germspk_natpop_zgde=total(native==1 & spklang=="German") 
bys zgde: egen frenspk_natpop_zgde=total(native==1 & spklang=="French") 
bys zgde: egen italspk_natpop_zgde=total(native==1 & spklang=="Italian") 
bys zgde: egen romaspk_natpop_zgde=total(native==1 & spklang=="Romansh")

foreach i in germ fren ital roma{
gen sh_`i'spk_natpop_zgde=`i'spk_natpop_zgde/natpop_zgde
}

gen majspklang_nat_zgde=1 if germspk_natpop_zgde>frenspk_natpop_zgde & germspk_natpop_zgde>italspk_natpop_zgde & germspk_natpop_zgde>romaspk_natpop_zgde
replace majspklang_nat_zgde=2 if frenspk_natpop_zgde>germspk_natpop_zgde & frenspk_natpop_zgde>italspk_natpop_zgde & frenspk_natpop_zgde>romaspk_natpop_zgde
replace majspklang_nat_zgde=3 if italspk_natpop_zgde>germspk_natpop_zgde & italspk_natpop_zgde>frenspk_natpop_zgde & italspk_natpop_zgde>romaspk_natpop_zgde
replace majspklang_nat_zgde=4 if romaspk_natpop_zgde>germspk_natpop_zgde & romaspk_natpop_zgde>frenspk_natpop_zgde & romaspk_natpop_zgde>italspk_natpop_zgde

keep if native == 1 & natspk==1
keep if altj>=25 & altj<=70

label var self_employed "Self empl."
label var weak_ftr "Weak FTR"
label var altj "Age"
label var household_nchild "# childs"
label var tertedu "High skilled"
label var years5abroad "Less than 5 years in SWZ"
label var swissnational "Citizen"
label define ftr 0 "strong-FTR" 1 "weak-FTR"
label values weak_ftr ftr
  
egen aor1_dis=group(aor1 district)
egen aor1_lng=group(aor1 spklang)
egen aor1_maj=group(aor1 majspklang_nat_zgde)

global indcontr = "female altj altj2 i.religion swissnational married household_nchild tertedu"
global contr ="$indcontr"
global sdcluster = "aor1_maj"

*** Table A8, column 1 - estimates on Swiss natives from the whole Switzerland
reghdfe self_employed weak_ftr $contr if (altj>=25 & employed==1), absorb(district aor1) vce(cluster $sdcluster)
outreg2 using "$output\natives", nocons keep(weak_ftr*) ctitle("Switzerland") label addtext(Individual controls, YES, Religion dummies, YES, District FE, YES, District of Birth FE, YES) tex(frag) excel replace nonotes

*** Table A8, column 2 - estimates on Swiss natives in multilingual cantons (Grabunded excluded)
reghdfe self_employed weak_ftr $contr if (altj>=25 & employed==1 & multil_kant_nograb==1), absorb(district aor1) vce(cluster $sdcluster)
outreg2 using "$output\natives", nocons keep(weak_ftr*) ctitle("Multilingual Cantons") label addtext(Individual controls, YES, Religion dummies, YES, District FE, YES, District of Birth FE, YES) tex(frag) excel append nonotes

*** Table A8, column 3 - estimates on Swiss natives in districts at the linguistic border in multilingual cantons (Grabunded excluded)
reghdfe self_employed weak_ftr $contr if (altj>=25 & employed==1 & multil_kant_nograb==1 & ling_border_dis60tr==1), absorb(district aor1) vce(cluster $sdcluster)
outreg2 using "$output\natives", nocons keep(weak_ftr*) ctitle("Linguistic Border") label addtext(Individual controls, YES, Religion dummies, YES, District FE, YES, District of Birth FE, YES) tex(frag) excel append nonotes

