unzipfile output961465243413697143.zip, replace
use ESS1-6e01_1_F1.dta, clear
// Label waves
label define essround 1 "2002" 2 "2004" 3 "2006" 4 "2008" 5 "2010" 6 "2012"
label val essround essround
// Keep only countries that contribute six observations
egen pickone = tag(cntry essround)
tab cntry essround if pickone // Look at no. of waves per country
egen numrounds = total(pickone), by(cntry) // Calculate no. of waves per country
keep if numrounds == 6
// Identify migrants
generate migrant = 1 if (brncntr == 2) & !missing(brncntr)
replace migrant = 2 if (brncntr == 1 & (facntr == 2 | mocntr == 2)) & !missing(brncntr, facntr, mocntr)
replace migrant = 0 if (brncntr == 1 & facntr == 1 & mocntr == 1) & !missing(brncntr, facntr, mocntr)
label define migrant 0 "Native" 1 "First-generation migrant" 2 "Second-generation migrant"
label value migrant migrant
// Generate country identifier
kountry cntry, from(iso2c)
rename NAMES_STD country
replace country = "Slovenia" if country == "si"
// By country, year, and migrant status
collapse (mean) imbgeco imueclt imwbcnt [pweight = dweight], by(country essround migrant)
drop if migrant == .
sort country migrant essround
twoway (connected imbgeco essround if migrant == 0, ///
by(country, note(" " "{it:Source:} European Social Survey, rounds 1{c 150}6, weighted data", span size(*.8)))) ///
(connected imbgeco essround if migrant == 1) ///
(connected imbgeco essround if migrant == 2) ///
, xlabel(1/6, val ang(v)) ytitle("Immigration good for economy") ysize(8) xtitle("") name(imbgecocym, replace) ///
legend(order(1 "Natives" ///
2 "First-gen." ///
3 "Second-gen.") ring(0) row(1))
May 4, 2016
Random graphs (80): Line plots using the -by- option
Labels:
collapse,
egen,
European Social Survey,
kountry,
Random graphs,
twoway connected,
unzipfile,
weight
