****************************************************************************************** ************ Before running the do file, please rename the downloaded version ************ ******************************* "wp-156_supp_stata_do.txt" ******************************* **************************** into a "real" Stata do-file like **************************** ********************************* "wp-156_supp_stata.do" ********************************* ****************************************************************************************** ****************************************************************************************** ****************** Supplementary Material to the MZES Working Paper 156 ****************** ****************************************************************************************** ********************* "Examining the Diversity of Youth in Europe - ********************** ********* A Classification of Generations and Ethnic Origins Using CILS4EU Data ********** ***********************************(Technical Report)" *********************************** ****************************************************************************************** ******************** Jörg Dollmann, Konstanze Jacob, and Frank Kalter ******************** ****************************************************************************************** ****************************************** 2014 ****************************************** ****************************************************************************************** * Version History and bugfixes * * ******************************** * v1.1.0 - changed on 14/05/2014 * * the value label of variable "generationG" for the values 1 and 3 are now reversed. * * value 1: label old: "1.75th generation" label new: "1.25th generation" * value 3: label old: "1.25th generation" label new: "1.75th generation" * * *** Help variables: Relationship of respondent and partner in parental interview *** * Respondent of parental interview is biological mother or father * gen resbio = . lab var resbio "respondent in parents interview" lab def resbio 1 "biological mother" 2 "biological father", modify lab val resbio resbio replace resbio = 1 if p1_reltc==1 & (p1_sex==2 | p1_sex < 0 | p1_sex==.) // respondent in parental interview is biological mother and respondents' sex is // female or missing replace resbio = 2 if p1_reltc==2 & (p1_sex==1 | p1_sex < 0 | p1_sex==.) // respondent in parental interview is biological father and respondents' sex is // male or missing * Partner of respondent in parental interview is biological mother or father * gen parbio = . lab var resbio "respondents partner in parents interview" lab def parbio 1 "biological mother" 2 "biological father", modify lab val parbio parbio replace parbio = 1 if p1_preltc==1 & p1_sex==1 // partner of respondent is biological parent and respondents' sex is male (thus: // partner should be female) replace parbio = 2 if p1_preltc==1 & p1_sex==2 // partner of respondent is biological parent and respondents' sex is female // (thus: partner should be male) *** Help variable: Survey country code *** gen sccode = . recode sccode .=826 if country==1 recode sccode .=276 if country==2 recode sccode .=528 if country==3 recode sccode .=752 if country==4 // variable sccode indicates the country where the survey took place *** Construction of best answers for country of birth variables *** * Best answer for respondent youth * gen cob = y1_cob if y1_cob >= 0 // best answer on country of birth of respondent // youth is taken from youth main questionnaire lab var cob "respondent youths country of birth (best answer)" lab copy y1_cob cob, replace lab val cob cob * Best answer for biological mother * gen cobm = . lab var cobm "mothers country of birth (best answer)" lab copy y1_cobm cobm, replace lab val cobm cobm replace cobm = p1_cob if resbio==1 // best answer on mothers' country of birth is parent respondents' country of // birth if this is the biological mother of the child replace cobm = p1_pcob if parbio==1 // best answer on mothers' country of birth is parent respondents' partners' // country of birth if this is the biological mother of the child recode cobm -99/-1=. replace cobm = y1_cobm if (cobm==. | cobm==0) & y1_cobm >= 0 & y1_cobm != sccode replace cobm = sccode if cobm==. & y1_cobm==sccode // information on biological mothers' country of birth is taken from youth main // questionnaire if this information cannot be determined using the parental // questionnaire (due to unit non-response, item non-response or when respondent // in parental interview or his/her partner is not the biological mother). If we // only know that mother is not born in the survey country, this information is // replaced if the child has answered a particular foreign country for its // biological mother * Best answer for biological father * gen cobf = . lab var cobf "fathers country of birth (best answer)" label copy y1_cob cobf, replace label value cobf cobf replace cobf = p1_cob if resbio==2 // best answer on fathers' country of birth is parent respondents' country of // birth if this is the biological father of the child replace cobf = p1_pcob if parbio==2 // best answer on fathers' country of birth is parent respondents' partners' // country of birth if this is the biological father of the child recode cobf -99/-1=. replace cobf = y1_cobf if (cobf==. | cobf==0) & y1_cobf >= 0 & y1_cobf != sccode replace cobf = sccode if cobf==. & y1_cobf==sccode // information on biological fathers' country of birth is taken from youth main // questionnaire if this information cannot be determined using the parental // questionnaire (due to unit non-response, item non-response or when respondent // in parental interview or his/her partner is not the biological father). If we // only know that father is not born in the survey country, this information is // replaced if the child has answered a particular foreign country for its // biological father * Best answer for maternal grandmother * gen cobmm = . lab var cobmm "maternal grandmothers country of birth (best answer)" lab copy y1_cob cobmm, replace lab val cobmm cobmm replace cobmm = p1_cobm if resbio==1 // best answer on maternal grandmothers' country of birth is country of birth of // mother of parental respondent if the parental respondent is the biological // mother of the child replace cobmm = p1_pcobm if parbio==1 // best answer on maternal grandmothers' country of birth is country of birth of // mother of parent respondents' partner if the partner of the parental respondent // is the biological mother of the child recode cobmm -99/-1=. replace cobmm = sccode if y1_cobmm==1 & cobmm==. // information that the maternal grandmother is born in the survey country is // taken from youth main questionnaire if this information cannot be determined // using the parental questionnaire (due to unit non-response, item non-response // or when respondent in parental interview or his/her partner is not the // biological mother) replace cobmm = 0 if y1_cobmm==2 & cobmm==. // information that the maternal grandmother is born outside the survey country is // taken from youth main questionnaire if this information cannot be determined // using the parental questionnaire (due to unit non-response, item non-response // or when respondent in parental interview or his/her partner is not the // biological mother) * Best answer for maternal grandfather * gen cobmf = . lab var cobmf "maternal grandfathers country of birth (best answer)" lab copy y1_cob cobmf, replace lab val cobmf cobmf replace cobmf = p1_cobf if resbio==1 // best answer on maternal grandfathers' country of birth is country of birth of // father of parental respondent if the parental respondent is the biological // mother of the child replace cobmf = p1_pcobf if parbio==1 // best answer on maternal grandfathers' country of birth is country of birth of // father of parent respondents' partner if the partner of the parental respondent // is the biological mother of the child recode cobmf -99/-1=. replace cobmf = sccode if y1_cobmf==1 & cobmf==. // information that the maternal grandfather is born in the survey country is // taken from youth main questionnaire if this information cannot be determined // using the parental questionnaire (due to unit non-response, item non-response // or when respondent in parental interview or his/her partner is not the // biological mother) replace cobmf = 0 if y1_cobmf==2 & cobmf==. // information that the maternal grandfather is born outside the survey country // is taken from youth main questionnaire if this information cannot be determined // using the parental questionnaire (due to unit non-response, item non-response // or when respondent in parental interview or his/her partner is not the // biological mother) * Best answer for paternal grandmother * gen cobfm = . lab var cobfm "paternal grandmothers country of birth (best answer)" lab copy y1_cob cobfm, replace lab val cobfm cobfm replace cobfm = p1_cobm if resbio==2 // best answer on paternal grandmothers' country of birth is country of birth of // mother of parental respondent if the parental respondent is the biological // father of the child replace cobfm = p1_pcobm if parbio==2 // best answer on paternal grandmothers' country of birth is country of birth of // mother of parent respondents' partner if the partner of the parental respondent // is the biological father of the child recode cobfm -99/-1=. replace cobfm = sccode if y1_cobfm==1 & cobfm==. // information that the paternal grandmother is born in the survey country is // taken from youth main questionnaire if this information cannot be determined // using the parental questionnaire (due to unit non-response, item non-response // or when respondent in parental interview or his/her partner is not the // biological father) replace cobfm = 0 if y1_cobfm==2 & cobfm==. // information that the paternal grandmother is born outside the survey country // is taken from youth main questionnaire if this information cannot be determined // using the parental questionnaire (due to unit non-response, item non-response // or when respondent in parental interview or his/her partner is not the // biological father) * Best answer for paternal grandfather * gen cobff = . lab var cobff "paternal grandfathers country of birth (best answer)" lab copy y1_cob cobff, replace lab value cobff cobff replace cobff = p1_cobf if resbio==2 // best answer on paternal grandfathers' country of birth is country of birth of // father of parental respondent if the parental respondent is the biological // father of the child replace cobff = p1_pcobf if parbio==2 // best answer on paternal grandfathers' country of birth is country of birth of // father of parent respondents' respondents' partner if the partner of the // parental respondent is the biological father of the child recode cobff (-99/-1=.) replace cobff = sccode if y1_cobff==1 & cobff==. // information that the paternal grandfather is born in the survey country is // taken from youth main questionnaire if this information cannot be determined // using the parental questionnaire (due to unit non-response, item non-response // or when respondent in parental interview or his/her partner is not the // biological father) replace cobff = 0 if y1_cobff==2 & cobff==. // information that the paternal grandfather is born outside the survey country // is taken from youth main questionnaire if this information cannot be determined // using the parental questionnaire (due to unit non-response, item non-response // or when respondent in parental interview or his/her partner is not the // biological father) *** Help variables: Differentiation whether born in survey country or abroad *** gen scborn = cob==sccode if cob < . // variable scborn differentiates between whether the respondent youth is survey // country-born (1) or not (0), missing values indicate item non-response gen mscborn = cobm==sccode if cobm < . // variable mscborn differentiates between whether the respondent's mother is survey // country-born (1) or not (0), missing values indicate item non-response gen fscborn = cobf==sccode if cobf < . // variable fscborn differentiates between whether the respondent's father is survey // country-born (1) or not (0), missing values indicate item non-response gen mmscborn = cobmm==sccode if cobmm < . // variable mmscborn differentiates between whether the maternal grandmother is // survey country-born (1) or not (0), missing values indicate item non-response gen mfscborn = cobmf==sccode if cobmf < . // variable mfscborn differentiates between whether the maternal grandfather is // survey country-born (1) or not (0), missing values indicate item non-response gen fmscborn = cobfm==sccode if cobfm < . // variable fmscborn differentiates between whether the paternal grandmother is // survey country-born (1) or not (0), missing values indicate item non-response gen ffscborn = cobff==sccode if cobff < . // variable ffscborn differentiates between whether the paternal grandfather is // survey country-born (1) or not (0), missing values indicate item non-response *** Treatment of missing cases *** * Original variables * foreach X of varlist scborn mscborn fscborn mmscborn mfscborn fmscborn ffscborn { gen `X'0 = `X' } // variables ending with 0 are not changed during the // whole do-file, they can therefore be used to look at // the original (not replaced) values foreach X of varlist cob cobm cobf cobmm cobmf cobfm cobff { gen `X'0 = `X' lab copy cob `X'0, replace lab val `X'0 `X'0 } // variables ending with 0 are not changed during the // whole do-file, they can therefore be used to look at // the original (not replaced) values * Flag-Variable: Missings (generational status) * egen genflag_miss_c = rowmiss(scborn) // counts number of missing values on scborn (whether child was born in survey // country or not) egen genflag_miss_p = rowmiss(mscborn fscborn) // counts number of missing values on mscborn and fscborn (whether parents were // born in survey country or not) egen genflag_miss_gp = rowmiss(mmscborn mfscborn fmscborn ffscborn) // counts number of missing values on mmscborn, mfscborn, fmscborn and ffscborn // (whether grandparents were born in survey country or not) gen genflag_miss = genflag_miss_c * 100 + genflag_miss_p * 10 + genflag_miss_gp lab var genflag_miss "flag variable indicating missing cases (generational status)" // flag-variable indicating patterns of missing values * Flag-Variable: Missings (country of origin) * egen coflag_miss_c = anycount(cob), v(0) // counts number of cases where we only know that the child was born abroad // (cob=0) egen coflag_miss_p = anycount(cobm cobf), v(0) // counts number of parents where we only know that the parent was born abroad // (cobm=0 and cobf=0) egen coflag_miss_gp = anycount(cobmm cobmf cobfm cobff), v(0) // counts number of grandparents where we only know that grandparent was born // abroad (cobmm=0, cobmf=0, cobfm=0, cobff=0) gen coflag_miss = (coflag_miss_gp + genflag_miss_gp) * 100 + /// (coflag_miss_p + genflag_miss_p) * 10 + /// (coflag_miss_c + genflag_miss_c) lab var coflag_miss "flag variable indicating missing cases (country of origin)" // flag variable indicating patterns of missing values note that the sum of // insufficient and completely missing information (using also the above created // variable) is calculated for every level drop coflag_miss_c coflag_miss_p coflag_miss_gp genflag_miss_c genflag_miss_p /// genflag_miss_gp * Rule 1: Top-down missing-replacement if descendant is foreign born * recode mscborn fscborn (.=0) if scborn==0 // if child is born abroad, mother and father are also born abroad (if this // information is missing) recode mmscborn mfscborn (.=0) if mscborn==0 // if mother is born abroad, maternal grandparents are also born abroad (if this // information is missing) recode fmscborn ffscborn (.=0) if fscborn==0 // if father is born abroad, paternal grandparents are also born abroad (if this // information is missing) * Rule 2: Complement grandparent-dyads * replace mmscborn = mfscborn if mmscborn==. // maternal grandmother is replaced by information on maternal grandfather if // former information is missing replace mfscborn = mmscborn if mfscborn==. // maternal grandfather is replaced by information on maternal grandmother if // former information is missing replace fmscborn = ffscborn if fmscborn==. // paternal grandmother is replaced by information on paternal grandfather if // former information is missing replace ffscborn = fmscborn if ffscborn==. // paternal grandfather is replaced by information on paternal grandmother if // former information is missing * Rule 3: Bottom-up missing replacement if ancestors are survey-country born * recode mscborn .=1 if mmscborn==1 | mfscborn==1 // if one or both maternal grandparents is/are born in the survey country, the // mother is also born in the survey country if this information is missing recode fscborn .=1 if fmscborn==1 | ffscborn==1 // if one or both paternal grandparents is/are born in the survey country, the // father is also born in the survey country if this information is missing recode scborn .=1 if mscborn==1 | fscborn==1 // if mother and/or father is/are born in the survey country, the child is also // born in the survey country if this information is missing * Rule 4: Replace missing triad by complete triad * * Rule 5: Replace one parent with other parent * * Rule 6: Replace completely missing grandparent-dyad information with known dyad * replace mscborn = fscborn if mscborn==. // mother is replaced by information on father if former information is missing replace fscborn = mscborn if fscborn==. // father is replaced by information on mother if former information is missing replace mmscborn = fmscborn if mmscborn==. // maternal grandmother is replaced by information on paternal grandmother if // former information is missing replace mfscborn = ffscborn if mfscborn==. // maternal grandfather is replaced by information on paternal grandfather if // former information is missing replace fmscborn = mmscborn if fmscborn==. // paternal grandmother is replaced by information on maternal grandmother if // former information is missing replace ffscborn = mfscborn if ffscborn==. // paternal grandfather is replaced by information on maternal grandfather if // former information is missing *** Generational status definition *** gen generation = . lab var generation "generational status definition (standard approach)" lab def generation 1"1.25th generation" /// 2"1.5th generation" /// 3"1.75th generation" /// 4"1st generation missing migration age" /// 5"2nd generation" /// 6"2.5th generation" /// 7"2.75th generation" /// 8"interethnic 2nd generation" /// 9"3rd generation" /// 10"3.25th generation" /// 11"3.5th generation" /// 12"interethnic 3rd generation" /// 13"3.75th generation" /// 14"native" /// 15"parents foreign-born no info on child" /// 16"child native-born no info on parents grandp. foreign-born" /// 17"child native-born, at least one ancestor foreign-born" /// 18"child native-born no info on parents and grandp." /// 19"child and parents native-born, no info on grandp." /// 20"no info on any actor", modify lab val generation generation replace generation = 1 if scborn==0 & y1_migage>10 // 1.25 generation if child is born abroad and migrated after the age of 10 replace generation = 2 if scborn==0 & y1_migage>=6 & y1_migage<=10 // 1.5 generation if child is born abroad and migrated between the age of 6 and 10 replace generation = 3 if scborn==0 & y1_migage<6 & y1_migage>=0 // 1.75 generation if child is born abroad and migrated after before the age of 6 replace generation = 4 if scborn==0 & y1_migage<0 // 1st generation with missing migration age if child is born abroad and migration // age is missing replace generation = 5 if scborn==1 & mscborn==0 & fscborn==0 // 2nd generation if child is survey country born and both parents are born abroad replace generation = 6 if scborn==1 & mscborn==0 & fscborn==1 & /// fmscborn==0 & ffscborn==0 replace generation = 6 if scborn==1 & mscborn==1 & mmscborn==0 & /// mfscborn==0 & fscborn==0 // 2.5 generation if child is survey country born, one parent is foreign born and // one parent is survey country born, but has two foreign born parents replace generation = 7 if scborn==1 & mscborn==0 & /// fscborn==1 & fmscborn==0 & ffscborn==1 replace generation = 7 if scborn==1 & mscborn==0 & /// fscborn==1 & fmscborn==1 & ffscborn==0 replace generation = 7 if scborn==1 & mscborn==1 & mmscborn==0 & mfscborn==1 & /// fscborn==0 replace generation = 7 if scborn==1 & mscborn==1 & mmscborn==1 & mfscborn==0 & /// fscborn==0 // 2.75 generation if child is survey country born, one parent is foreign born and // one parent is survey country born, but has one parent who is foreign born and // one parent who is survey country born replace generation = 8 if scborn==1 & mscborn==0 & /// fscborn==1 & fmscborn==1 & ffscborn==1 replace generation = 8 if scborn==1 & mscborn==1 & mmscborn==1 & mfscborn==1 & /// fscborn==0 // Interethnic 2nd generation if child is survey country born, one parent is // foreign born and one parent is survey country born with two survey country born // parents replace generation = 9 if scborn==1 & mscborn==1 & mmscborn==0 & mfscborn==0 & /// fscborn==1 & fmscborn==0 & ffscborn==0 // 3rd generation if child and both parents are survey country born, all four // grandparents are foreign born replace generation = 10 if scborn==1 & mscborn==1 & mmscborn==0 & /// mfscborn==0 & fscborn==1 & fmscborn==0 & ffscborn==1 replace generation = 10 if scborn==1 & mscborn==1 & mmscborn==0 & /// mfscborn==0 & fscborn==1 & fmscborn==1 & ffscborn==0 replace generation = 10 if scborn==1 & mscborn==1 & mmscborn==0 & /// mfscborn==1 & fscborn==1 & fmscborn==0 & ffscborn==0 replace generation = 10 if scborn==1 & mscborn==1 & mmscborn==1 & /// mfscborn==0 & fscborn==1 & fmscborn==0 & ffscborn==0 // 3.25 generation if child and both parents are survey country born, three // grandparents are foreign born, one grandparent is survey country born replace generation = 11 if scborn==1 & mscborn==1 & mmscborn==0 & /// mfscborn==1 & fscborn==1 & fmscborn==0 & ffscborn==1 replace generation = 11 if scborn==1 & mscborn==1 & mmscborn==0 & /// mfscborn==1 & fscborn==1 & fmscborn==1 & ffscborn==0 replace generation = 11 if scborn==1 & mscborn==1 & mmscborn==1 & /// mfscborn==0 & fscborn==1 & fmscborn==0 & ffscborn==1 replace generation = 11 if scborn==1 & mscborn==1 & mmscborn==1 & /// mfscborn==0 & fscborn==1 & fmscborn==1 & ffscborn==0 // 3.5 generation if child and both parents are survey country born, but both // parents have one foreign born parent and one survey country born parent replace generation = 12 if scborn==1 & mscborn==1 & mmscborn==0 & /// mfscborn==0 & fscborn==1 & fmscborn==1 & ffscborn==1 replace generation = 12 if scborn==1 & mscborn==1 & mmscborn==1 & /// mfscborn==1 & fscborn==1 & fmscborn==0 & ffscborn==0 // Interethnic 3rd generation if child and both parents are survey country, one // parent has two survey country born parents and the other has two foreign born // parents replace generation = 13 if scborn==1 & mscborn==1 & mmscborn==0 & /// mfscborn==1 & fscborn==1 & fmscborn==1 & ffscborn==1 replace generation = 13 if scborn==1 & mscborn==1 & mmscborn==1 & /// mfscborn==0 & fscborn==1 & fmscborn==1 & ffscborn==1 replace generation = 13 if scborn==1 & mscborn==1 & mmscborn==1 & /// mfscborn==1 & fscborn==1 & fmscborn==0 & ffscborn==1 replace generation = 13 if scborn==1 & mscborn==1 & mmscborn==1 & /// mfscborn==1 & fscborn==1 & fmscborn==1 & ffscborn==0 // 3.75 generation if child and both parents are survey country born, one // grandparent is foreign born, three grandparents are survey country born replace generation = 14 if scborn==1 & mscborn==1 & mmscborn==1 & /// mfscborn==1 & fscborn==1 & fmscborn==1 & ffscborn==1 // Native if child, both parents and four grandparents are survey country born replace generation = 14 if scborn==1 & y1_mh1_ge==2 & generation==. // Native if child is survey country born and has no immigration background replace generation = 15 if scborn==. & mscborn==0 & fscborn==0 // Parents are foreign born, no information on child replace generation = 16 if scborn==1 & mscborn==. & fscborn==. & /// mmscborn==0 & mfscborn==0 & fmscborn==0 & ffscborn==0 & fed_ge!=10 // Child is survey country born, no information on parents, grandparents are // foreign born replace generation = 17 if scborn==1 & mscborn==. & fscborn==. & y1_mh1_ge==1 // Child is survey country born, at least one ancestry is foreign born replace generation = 18 if scborn==1 & mscborn==. & fscborn==. & /// mmscborn==. & mfscborn==. & fmscborn==. & ffscborn==. & fed_ge!=10 // Child is survey country born, no information on parents and grandparents replace generation = 19 if scborn==1 & mscborn==1 & fscborn==1 & /// mmscborn==. & mfscborn==. & fmscborn==. & ffscborn==. & fed_ge!=10 // Child and parents are survey country born, no information on grandparents replace generation = 20 if scborn==. & mscborn==. & fscborn==. & /// mmscborn==. & mfscborn==. & fmscborn==. & ffscborn==. // No information on any actor *** Country of origin definition *** gen countorig = . lab var countorig "country of origin" lab copy cob countorig, replace lab def countorig 999"not sure whether native or immigrant", modify lab val countorig countorig replace countorig = sccode if generation==14 // Country of origin is survey country if all four grandparents are born in the // survey country replace countorig = cobmm if /// (((cobmm==cobmf) | (cobmm==cobfm) | (cobmm==cobff)) | /// ((cobmf==. | cobmf==sccode | cobmf==0) & /// (cobfm==. | cobfm==sccode | cobfm==0) & /// (cobff==. | cobff==sccode | cobff==0)) | ((cobmm != cobmf) & /// (cobmm != cobfm) & (cobmm != cobff) & (cobmf != cobfm) & /// (cobmf != cobff) & (cobfm != cobff)) | ((cobmm != cobmf) & /// (cobmm != cobfm) & (cobmf != cobfm) & /// (cobff==. | cobff==sccode | cobff==0)) | ((cobmm != cobmf) & /// (cobmm != cobff) & (cobmf != cobff) & /// (cobfm==. | cobfm==sccode | cobfm==0)) | ((cobmm != cobfm) & /// (cobmm != cobff) & (cobfm != cobff) & /// (cobmf==. | cobmf==sccode | cobmf==0)) | ((cobmm != cobmf) & /// (cobfm==. | cobfm==sccode | cobfm==0) & /// (cobff==. | cobff==sccode | cobff==0)) | ((cobmm != cobfm) & /// (cobmf==. | cobmf==sccode | cobmf==0) & /// (cobff==. | cobff==sccode | cobff==0)) | ((cobmm != cobff) & /// (cobmf==. | cobmf==sccode | cobmf==0) & /// (cobfm==. | cobfm==sccode | cobfm==0))) & /// cobmm != . & cobmm != sccode & cobmm != 0 & countorig==. // Maternal grandmother's country of birth defines country of origin if: // - maternal grandmother' country of birth is not missing and not the // survey country AND // - at least one grandparent is born in the same country as maternal // grandmother OR // - maternal grandmother is the only non-missing foreign country OR // - or all non-missing foreign countries differ from each other replace countorig = cobmf if /// (((cobmm==. | cobmm==sccode | cobmm==0) & ((cobmf==cobfm) | /// (cobmf==cobff)) | ((cobfm==. | cobfm==sccode | cobfm==0) & /// (cobff==. | cobff==sccode | cobff==0)) | ((cobmf != cobfm) & /// (cobmf != cobff) & (cobfm != cobff)) | ((cobmf != cobfm) & /// (cobff==. | cobff==sccode | cobff==0)) | ((cobmf != cobff) & /// (cobfm==. | cobfm==sccode | cobfm==0))) | /// ((cobmm != . & cobmm != sccode & cobmm != 0) & ((cobmf==cobfm) | /// (cobmf==cobff) & (cobmm != cobmf)))) & /// cobmf != . & cobmf != sccode & cobmf != 0 & countorig==. // Maternal grandfather's country of birth defines country of origin if: // - maternal country of birth is missing or the survey country AND // - at least one grandparent is born in the same country as maternal // grandfather OR // - maternal grandfather is the only non-missing foreign country OR // - or all non-missing foreign countries differ from each other // - OR maternal country if birth is foreign country AND // - maternal grandparents are born in different countries while at least // one grandparent on father's side is born in the same country as // maternal grandfather // - AND maternal grandfather' country of birth is not missing and not the // survey country replace countorig = cobfm if /// (((cobmm==. | cobmm==sccode | cobmm==0) & /// (cobmf==. | cobmf==sccode | cobmf==0)) | ((cobmm != cobmf) & /// (cobmm != cobfm) & (cobmm != cobff) & (cobmf != cobfm) & /// (cobmf != cobff) & (cobfm==cobff))) & (cobfm != . & /// cobfm != sccode & cobfm != 0) & countorig==. // Paternal grandmother's country of birth defines country of origin if: // - paternal grandmother' country of birth is not missing and not the survey // country AND // - both maternal grandparents' countries of birth are missing // - paternal grandparents are born in the same country while maternal // grandparents are born in different countries replace countorig = cobff if /// ((cobmm==. | cobmm==sccode | cobmm==0) & /// (cobmf==. | cobmf==sccode | cobmf==0) & /// (cobfm==. | cobfm==sccode | cobfm==0)) & /// (cobff != . & cobff != sccode & cobff != 0) & countorig==. // Paternal grandfather defines country of origin if this is the only non- // missing foreign country among all four grandparents replace countorig = cobm if (cobm != . & cobm != sccode & cobm != 0) & /// countorig==. // Mother defines country of origin if we don't have any foreign country of birth // information on grandparent level replace countorig = cobf if (cobf != . & cobf != sccode & cobf != 0) & /// countorig==. // Father defines country of origin if we don't have any foreign country of birth // information on grandparent level as well as for mother replace countorig = cob if (cob != . & cob != sccode & cob != 0) & countorig==. // Mother defines country of origin if we don't have any foreign country of birth // information on grandparent and parent level replace countorig = 999 if (cob==sccode | cob==.) & (cobm==sccode | cobm==.) & /// (cobf==sccode | cobf==.) & (cobmm==sccode | cobmm==.) & /// (cobmf==sccode | cobmf==.) & (cobfm==sccode | cobfm==.) & /// (cobff==sccode | cobff==.) & countorig==. // code "not sure whether immigrant or native" if at least information on one // actor is missing but no actor is certainly foreign born replace countorig = 0 if /// (cob==0 | cobm==0 | cobf==0 | cobmm==0 | cobmf==0 | cobfm==0 | cobff==0) & /// countorig==. // code "outside survey country" if at least information on one actor is // "foreign born" but no information on particular country for any of the 7 // actors *** Non-trivial cases (generational status) *** * Flag-Variable: Non-trivial cases (generational status) * egen genflag_nt_p = anycount(mscborn0 fscborn0) if scborn0==0, v(1) // counts number of parents who are survey country born although the child is born // abroad egen genflag_nt_gp1 = anycount(mmscborn0 mfscborn0 fmscborn0 ffscborn0) /// if scborn0==0, v(1) // counts number of grandparents who are survey country born although the // child is born abroad egen genflag_nt_gp2 = anycount(mmscborn0 mfscborn0) /// if (scborn0==1 | scborn0==.) & mscborn0==0, v(1) // counts number of maternal grandparents who are survey country born although // the mother is born abroad egen genflag_nt_gp3 = anycount(fmscborn0 ffscborn0) /// if (scborn0==1 | scborn0==.) & fscborn0==0, v(1) // counts number of paternal grandparents who are survey country born although // the father is born abroad gen genflag_nt_gp = genflag_nt_gp1 + genflag_nt_gp2 + genflag_nt_gp3 gen genflag_nt = genflag_nt_p * 10 + genflag_nt_gp lab var genflag_nt /// "flag variable indicating non-trivial cases (generational status)" // flag-variable indicating patterns of non-trivial cases (generation) drop genflag_nt_p genflag_nt_gp1 genflag_nt_gp2 genflag_nt_gp3 genflag_nt_gp *** Non-trivial cases (country of origin) *** * Flag-Variable: Non-trivial cases (country of origin) * gen coflag_nt_c = (cob0 != countorig) & (cob0 != . & cob0 != sccode & cob0 != 0) // indicates whether the child's country of birth equals its country of origin gen coflag_nt_m = (cobm0 != countorig) & /// (cobm0 != . & cobm0 != sccode & cobm0 != 0) gen coflag_nt_f = (cobf0 != countorig) & /// (cobf0 != . & cobf0 != sccode & cobf0 != 0) egen coflag_nt_p = rowtotal(coflag_nt_m coflag_nt_f) // counts number of parents' countries of birth unequal to child's country of // origin gen coflag_nt_mm = (cobmm0 != countorig) & /// (cobmm0 != . & cobmm0 != sccode & cobmm0 != 0) gen coflag_nt_mf = (cobmf0 != countorig) & /// (cobmf0 != . & cobmf0 != sccode & cobmf0 != 0) gen coflag_nt_fm = (cobfm0 != countorig) & /// (cobfm0 != . & cobfm0 != sccode & cobfm0 != 0) gen coflag_nt_ff = (cobff0 != countorig) & /// (cobff0 != . & cobff0 != sccode & cobff0 != 0) egen coflag_nt_gp = rowtotal(coflag_nt_mm coflag_nt_mf coflag_nt_fm coflag_nt_ff) // counts number of grandparents' countries of birth unequal to child's country of // origin gen coflag_nt = coflag_nt_gp * 100 + coflag_nt_p * 10 + coflag_nt_c lab var coflag_nt "flag variable indicating non-trivial cases (country of origin)" // flag-variable indicating patterns of non-trivial cases (country of origin) drop coflag_nt_c coflag_nt_m coflag_nt_f coflag_nt_p coflag_nt_mm coflag_nt_mf /// coflag_nt_fm coflag_nt_ff coflag_nt_gp *** The country of origin revisited *** gen countorig_rev = countorig lab copy countorig countorig_rev, replace lab val countorig_rev countorig_rev // creates new variable "revisited" * Parental information * * Nationality * gen nationp = p1_nation1 /// if p1_nation1>0 & p1_nation1<1000 & p1_nation1!=sccode replace nationp = p1_nation2 /// if p1_nation2>0 & p1_nation2<1000 & p1_nation2!=sccode gen pnationp = p1_pnation1 /// if p1_pnation1>0 & p1_pnation1<1000 & p1_pnation1!=sccode replace pnationp = p1_pnation2 /// if p1_pnation2>0 & p1_pnation2<1000 & p1_pnation2!=sccode replace countorig_rev = nationp /// if (countorig_rev==0 | countorig_rev==999) & /// (resbio==1 | resbio==2) & nationp<. // nationality of parent is used when the country of origin is missing // and the parent in the parental interview is a biological parent replace countorig_rev = pnationp /// if (countorig_rev==0 | countorig_rev==999) & /// (parbio==1 | parbio==2) & pnationp<. // nationality of parents' partner is used when the country of origin is // missing and the partner is a biological parent * Identity * foreach X of varlist p1_idoc1a p1_idoc1b p1_idoc1c p1_idoc1d p1_idoc1e /// p1_idoc1f p1_idoc1g p1_idoc1h p1_idoc1i { recode `X' -99/-1 910/. 0=., gen(`X'_miss) } gen identp = p1_idoc1a_miss foreach X in a b c d e f g h i { replace identp = p1_idoc1`X'_miss if identp==. } replace countorig_rev = identp /// if (countorig_rev==0 | countorig_rev==999) & /// (resbio==1 | resbio==2) & identp<. // identity of parent is used when the country of origin is still missing // and the parent in the parental interview is a biological parent drop p1_idoc1a_miss p1_idoc1b_miss p1_idoc1c_miss p1_idoc1d_miss /// p1_idoc1e_miss p1_idoc1f_miss p1_idoc1g_miss p1_idoc1h_miss /// p1_idoc1i_miss * Child's information * * Nationality * gen nationy = y1_nation1 /// if y1_nation1>0 & y1_nation1<1000 & y1_nation1!=sccode replace nationy = y1_nation2 /// if y1_nation2>0 & y1_nation2<1000 & y1_nation2!=sccode replace countorig_rev = nationy /// if (countorig_rev==0 | countorig_rev==999) & nationy<. // child's nationality is used when the country of origin is still missing * Identity * foreach X of varlist y1_idoc1a y1_idoc1b y1_idoc1c y1_idoc1d y1_idoc1e /// y1_idoc1f y1_idoc1g y1_idoc1h y1_idoc1i y1_idoc1j y1_idoc1k y1_idoc1l /// y1_idoc1m { recode `X' -99/-1 910/. 0=., gen(`X'_miss) } gen identy = y1_idoc1a_miss foreach X in a b c d e f g h i j k l m { replace identy = y1_idoc1`X'_miss if identy==. } replace countorig_rev = identy /// if (countorig_rev==0 | countorig_rev==999) & identy<. // child's identity is used when the country of origin is still missing drop y1_idoc1a_miss y1_idoc1b_miss y1_idoc1c_miss y1_idoc1d_miss /// y1_idoc1e_miss y1_idoc1f_miss y1_idoc1g_miss y1_idoc1h_miss /// y1_idoc1i_miss y1_idoc1j_miss y1_idoc1k_miss y1_idoc1l_miss /// y1_idoc1m_miss * Migration background * foreach X of varlist y1_mh2* { recode `X' -99/0=., gen(`X'_miss) } gen mh = y1_mh2a_ge_miss replace countorig_rev = mh /// if (countorig_rev==0 | countorig_rev==999) & mh<. // child's migration background is used when the country of origin is // still missing drop y1_mh2a_ge_miss y1_mh2b_ge_miss replace countorig_rev = mh if countorig_rev==identy & identy==901 & mh==422 replace countorig_rev = mh if countorig_rev==identy & identy==2 & mh==710 replace countorig_rev = mh if countorig_rev==identy & identy==901 & mh==275 // Deviation from replacement order if later information is more specific than // former information * Flag-Variable: Use of additional information (country of origin) * gen coflag_ai = 0 if countorig_rev>0 & countorig_rev<999 recode coflag_ai 0=1 if countorig_rev!=countorig & /// ((countorig_rev==nationp & (resbio==1 | resbio==2)) | /// (countorig_rev==pnationp & (parbio==1 | parbio==2))) recode coflag_ai 0=4 if countorig_rev!=countorig & /// countorig_rev==identp & (resbio==1 | resbio==2) recode coflag_ai 0=2 if countorig_rev!=countorig & /// countorig_rev==nationy recode coflag_ai 0=5 if countorig_rev!=countorig & /// countorig_rev==identy recode coflag_ai 0=3 if countorig_rev!=countorig & /// countorig_rev==mh recode coflag_ai .=6 if countorig_rev==0 | countorig_rev==999 lab var coflag_ai /// "flag variable indicating use of additional information (country of origin)" lab def coflag_ai 0"countries of birth" 1"parents nationality" /// 2"childs nationality" 3"childs migration background" /// 4"parents identity" 5"childs identity" /// 6"no information on any variable", modify lab val coflag_ai coflag_ai replace countorig = countorig_rev drop nationp pnationp identp nationy identy mh countorig_rev *** Classifications of country of origin *** * England * gen countorig_en = . recode countorig_en .=1 if countorig==826 lab def countorig_en 1"United Kingdom of Great Britain and Northern Ireland", modify recode countorig_en .=2 if countorig==586 lab def countorig_en 2"Pakistan", modify recode countorig_en .=3 if countorig==356 lab def countorig_en 3"India", modify recode countorig_en .=4 if countorig==388 lab def countorig_en 4"Jamaica", modify recode countorig_en .=5 if countorig==372 lab def countorig_en 5"Ireland", modify recode countorig_en .=6 if countorig==566 lab def countorig_en 6"Nigeria", modify recode countorig_en .=7 if countorig==50 lab def countorig_en 7"Bangladesh", modify recode countorig_en .=8 if inlist(countorig, /// 108,174,262,232,231,404,450,454,480,175,508,638,646,690,706,800,834,894, /// 716,14) lab def countorig_en 8"Eastern Africa", modify recode countorig_en .=9 if inlist(countorig, /// 204,854,132,384,270,288,324,624,430,466,478,562,566,654,686,694,768,11) lab def countorig_en 9"Western Africa", modify recode countorig_en .=10 if inlist(countorig, /// 12,901,818,434,504,728,729,788,732,15) recode countorig_en .=10 if inlist(countorig, /// 24,120,140,148,178,180,226,266,678,17) recode countorig_en .=10 if inlist(countorig, 72,426,516,710,748,18) recode countorig_en .=10 if countorig==2 lab def countorig_en 10"Other Africa", modify recode countorig_en .=11 if inlist(countorig, /// 660,28,533,44,52,535,92,136,192,531,212,214,308,312,332,388,474,500,530, /// 630,652,659,662,663,670,534,780,796,850,29,419) recode countorig_en .=11 if inlist(countorig, 84,188,222,320,340,484,558,591,13) recode countorig_en .=11 if inlist(countorig, 32,68,76,152,170,218,238,254, /// 328,600,604,740,858,862,5) lab def countorig_en 11"Latin America and the Caribbean", modify recode countorig_en .=12 if inlist(countorig, 60,124,304,666,840) recode countorig_en .=12 if countorig==19 recode countorig_en .=12 if inlist(countorig, 36,554,574,53) recode countorig_en .=12 if inlist(countorig, 242,540,598,90,548) recode countorig_en .=12 if inlist(countorig, /// 16,184,258,570,612,882,772,776,798,876) lab def countorig_en 12"Northern America and Oceania", modify recode countorig_en .=13 if inlist(countorig, 4,50,64,356,364,906,462,524, /// 586,144,34) lab def countorig_en 13"Southern Asia", modify recode countorig_en .=14 if inlist(countorig, 156,344,446,408,392,496,410,30) lab def countorig_en 14"Eastern Asia", modify recode countorig_en .=15 if inlist(countorig, /// 905,51,31,48,196,268,368,376,400,904,414,422,275,512,634,682,760,792,784, /// 887,145) recode countorig_en .=15 if inlist(countorig, /// 96,116,360,418,458,104,608,702,764,626,704,35) recode countorig_en .=15 if inlist(countorig, 398,417,762,795,860,143) recode countorig_en .=15 if countorig==142 lab def countorig_en 15"Other Asia", modify recode countorig_en .=16 if inlist(countorig, /// 112,100,200,203,348,616,498,642,643,703,804,810,151) recode countorig_en .=16 if countorig==902 lab def countorig_en 16"Eastern Europe", modify recode countorig_en .=17 if inlist(countorig, /// 8,20,70,191,292,300,336,380,903,470,499,620,674,688,891,907,705,890,724, /// 807,39) lab def countorig_en 17"Southern Europe", modify recode countorig_en .=18 if inlist(countorig, /// 248,830,208,233,234,246,831,352,372,833,832,428,440,578,680,744,752,826,154) recode countorig_en .=18 if inlist(countorig, /// 40,56,250,276,438,442,492,528,756,155) lab def countorig_en 18"Other Europe", modify recode countorig_en .=19 if countorig==0 lab def countorig_en 19"Unknown country of origin", modify recode countorig_en .=20 if countorig==999 lab def countorig_en 20"Unknown immigrant background", modify replace countorig_en = -66 if country!=1 lab def countorig_en -66"question not asked", modify lab var countorig_en "country of origin - national classification (england)" lab val countorig_en countorig_en * Germany * gen countorig_ge = . recode countorig_ge .=1 if countorig==276 lab def countorig_ge 1"Germany", modify recode countorig_ge .=2 if countorig==792 recode countorig_ge .=2 if countorig==904 lab def countorig_ge 2"Turkey", modify recode countorig_ge .=3 if inlist(countorig, /// 643,398,804,112,498,804,810,417,268,31,51) lab def countorig_ge 3"Former Soviet Union", modify recode countorig_ge .=4 if countorig==616 lab def countorig_ge 4"Poland", modify recode countorig_ge .=5 if inlist(countorig, 70,191,499,688,705,807,890,891,903) lab def countorig_ge 5"Former Yugoslavia", modify recode countorig_ge .=6 if countorig==380 lab def countorig_ge 6"Italy", modify recode countorig_ge .=7 if countorig==422 lab def countorig_ge 7"Lebanon", modify recode countorig_ge .=8 if countorig==300 lab def countorig_ge 8"Greece", modify recode countorig_ge .=9 if inlist(countorig, /// 12,901,818,434,504,728,729,788,732,15) lab def countorig_ge 9"Northern Africa", modify recode countorig_ge .=10 if inlist(countorig, /// 108,174,262,232,231,404,450,454,480,175,508,638,646,690,706,800,834,894, /// 716,14) recode countorig_ge .=10 if inlist(countorig, /// 24,120,140,148,178,180,226,266,678,17) recode countorig_ge .=10 if inlist(countorig, /// 72,426,516,710,748,18) recode countorig_ge .=10 if inlist(countorig, /// 204,854,132,384,270,288,324,624,430,466,478,562,566,654,686,694,768,11) recode countorig_ge .=10 if countorig==2 lab def countorig_ge 10"Other Africa", modify recode countorig_ge .=11 if inlist(countorig, /// 660,28,533,44,52,535,92,136,192,531,212,214,308,312,332,388,474,500,530, /// 630,652,659,662,663,670,534,780,796,850,29,419) recode countorig_ge .=11 if inlist(countorig, /// 84,188,222,320,340,484,558,591,13) recode countorig_ge .=11 if inlist(countorig, /// 32,68,76,152,170,218,238,254,328,600,604,740,858,862,5) lab def countorig_ge 11"Latin America and the Caribbean", modify recode countorig_ge .=12 if inlist(countorig, 60,124,304,666,840) recode countorig_ge .=12 if countorig==19 recode countorig_ge .=12 if inlist(countorig, 36,554,574,53) lab def countorig_ge 12"Northern America and Oceania", modify recode countorig_ge .=13 if inlist(countorig, /// 4,50,64,356,364,906,462,524,586,144,34) lab def countorig_ge 13"Southern Asia", modify recode countorig_ge .=14 if inlist(countorig, /// 905,51,31,48,196,268,368,376,400,904,414,422,275,512,634,682,760,792,784, /// 887,145) lab def countorig_ge 14"Western Asia", modify recode countorig_ge .=15 if inlist(countorig, 398,417,762,795,860,143) recode countorig_ge .=15 if inlist(countorig, 156,344,446,408,392,496,410,30) recode countorig_ge .=15 if inlist(countorig, /// 96,116,360,418,458,104,608,702,764,626,704,35) recode countorig_ge .=15 if countorig==142 lab def countorig_ge 15"Other Asia", modify recode countorig_ge .=16 if inlist(countorig, /// 112,100,200,203,348,616,498,642,643,703,804,810,151) recode countorig_ge .=16 if countorig==902 lab def countorig_ge 16"Eastern Europe", modify recode countorig_ge .=17 if inlist(countorig, /// 8,20,70,191,292,300,336,380,903,470,499,620,674,688,891,907,705,890,724, /// 807,39) lab def countorig_ge 17"Southern Europe", modify recode countorig_ge .=18 if inlist(countorig, /// 248,830,208,233,234,246,831,352,372,833,832,428,440,578,680,744,752,826,154) recode countorig_ge .=18 if inlist(countorig, /// 40,56,250,276,438,442,492,528,756,155) lab def countorig_ge 18"Other Europe", modify recode countorig_ge .=19 if countorig==0 lab def countorig_ge 19"Unknown country of origin", modify recode countorig_ge .=20 if countorig==999 lab def countorig_ge 20"Unknown immigrant background", modify replace countorig_ge = -66 if country!=2 lab def countorig_ge -66"question not asked", modify lab var countorig_ge "country of origin - national classification (germany)" lab val countorig_ge countorig_ge * Netherlands * gen countorig_nl = . recode countorig_nl .=1 if countorig==528 lab def countorig_nl 1"Netherlands", modify recode countorig_nl .=2 if countorig==792 recode countorig_nl .=2 if countorig==904 lab def countorig_nl 2"Turkey", modify recode countorig_nl .=3 if countorig==504 lab def countorig_nl 3"Morocco", modify recode countorig_nl .=4 if countorig==740 lab def countorig_nl 4"Suriname", modify recode countorig_nl .=5 if countorig==360 lab def countorig_nl 5"Indonesia", modify recode countorig_nl .=6 if inlist(countorig, 533,531,535,534,530) lab def countorig_nl 6"Netherlands Antilles", modify recode countorig_nl .=7 if countorig==276 lab def countorig_nl 7"Germany", modify recode countorig_nl .=8 if inlist(countorig, /// 108,174,262,232,231,404,450,454,480,175,508,638,646,690,706,800,834,894, /// 716,14) recode countorig_nl .=8 if inlist(countorig, /// 12,901,818,434,504,728,729,788,732,15) recode countorig_nl .=8 if inlist(countorig, /// 24,120,140,148,178,180,226,266,678,17) recode countorig_nl .=8 if inlist(countorig, /// 72,426,516,710,748,18) recode countorig_nl .=8 if inlist(countorig, /// 204,854,132,384,270,288,324,624,430,466,478,562,566,654,686,694,768,11) recode countorig_nl .=8 if countorig==2 lab def countorig_nl 8"Africa", modify recode countorig_nl .=9 if inlist(countorig, /// 660,28,533,44,52,535,92,136,192,531,212,214,308,312,332,388,474,500,530, /// 630,652,659,662,663,670,534,780,796,850,29,419) recode countorig_nl .=9 if inlist(countorig, 84,188,222,320,340,484,558,591,13) recode countorig_nl .=9 if inlist(countorig, /// 32,68,76,152,170,218,238,254,328,600,604,740,858,862,5) lab def countorig_nl 9"Latin America and the Caribbean", modify recode countorig_nl .=10 if inlist(countorig, 60,124,304,666,840) recode countorig_nl .=10 if countorig==19 recode countorig_nl .=10 if inlist(countorig, 36,554,574,53) recode countorig_nl .=10 if inlist(countorig, 242,540,598,90,548) lab def countorig_nl 10"Northern America and Oceania", modify recode countorig_nl .=11 if inlist(countorig, /// 4,50,64,356,364,906,462,524,586,144,34) lab def countorig_nl 11"Southern Asia", modify recode countorig_nl .=12 if inlist(countorig, /// 905,51,31,48,196,268,368,376,400,904,414,422,275,512,634,682,760,792,784, /// 887,145) lab def countorig_nl 12"Western Asia", modify recode countorig_nl .=13 if inlist(countorig, /// 96,116,360,418,458,104,608,702,764,626,704,35) recode countorig_nl .=13 if inlist(countorig, /// 398,417,762,795,860,143) recode countorig_nl .=13 if inlist(countorig, /// 156,344,446,408,392,496,410,30) recode countorig_nl .=13 if countorig==142 lab def countorig_nl 13"Other Asia", modify recode countorig_nl .=14 if inlist(countorig, /// 8,20,70,191,292,300,336,380,903,470,499,620,674,688,891,907,705,890,724, /// 807,39) lab def countorig_nl 14"Southern Europe", modify recode countorig_nl .=15 if inlist(countorig, /// 40,56,250,276,438,442,492,528,756,155) lab def countorig_nl 15"Western Europe", modify recode countorig_nl .=16 if inlist(countorig, /// 112,100,200,203,348,616,498,642,643,703,804,810,151) recode countorig_nl .=16 if countorig==902 recode countorig_nl .=16 if inlist(countorig, /// 248,830,208,233,234,246,831,352,372,833,832,428,440,578,680,744,752,826,154) lab def countorig_nl 16"Other Europe", modify recode countorig_nl .=17 if countorig==0 lab def countorig_nl 17"Unknown country of origin", modify recode countorig_nl .=18 if countorig==999 lab def countorig_nl 18"Unknown immigrant background", modify replace countorig_nl = -66 if country!=3 lab def countorig_nl -66"question not asked", modify lab var countorig_nl "country of origin - national classification (netherlands)" lab val countorig_nl countorig_nl * Sweden * gen countorig_sw = . recode countorig_sw .=1 if countorig==752 lab def countorig_sw 1"Sweden", modify recode countorig_sw .=2 if inlist(countorig, 70,191,499,688,705,807,890,891,903) lab def countorig_sw 2"Former Yugoslavia", modify recode countorig_sw .=3 if countorig==246 lab def countorig_sw 3"Finland", modify recode countorig_sw .=4 if countorig==368 lab def countorig_sw 4"Iraq", modify recode countorig_sw .=5 if countorig==792 recode countorig_sw .=5 if countorig==904 lab def countorig_sw 5"Turkey", modify recode countorig_sw .=6 if countorig==706 lab def countorig_sw 6"Somalia", modify recode countorig_sw .=7 if countorig==422 lab def countorig_sw 7"Lebanon", modify recode countorig_sw .=8 if countorig==760 lab def countorig_sw 8"Syrian Arab Republic", modify recode countorig_sw .=9 if countorig==276 lab def countorig_sw 9"Germany", modify recode countorig_sw .=10 if countorig==364 lab def countorig_sw 10"Islamic Republic of Iran", modify recode countorig_sw .=11 if countorig==616 lab def countorig_sw 11"Poland", modify recode countorig_sw .=12 if countorig==208 lab def countorig_sw 12"Denmark", modify recode countorig_sw .=13 if countorig==578 lab def countorig_sw 13"Norway", modify recode countorig_sw .=14 if inlist(countorig, /// 108,174,262,232,231,404,450,454,480,175,508,638,646,690,706,800,834,894, /// 716,14) lab def countorig_sw 14"Eastern Africa", modify recode countorig_sw .=15 if inlist(countorig, /// 12,901,818,434,504,728,729,788,732,15) lab def countorig_sw 15"Northern Africa", modify recode countorig_sw .=16 if inlist(countorig, /// 24,120,140,148,178,180,226,266,678,17) recode countorig_sw .=16 if inlist(countorig, 72,426,516,710,748,18) recode countorig_sw .=16 if inlist(countorig, /// 204,854,132,384,270,288,324,624,430,466,478,562,566,654,686,694,768,11) recode countorig_sw .=16 if countorig==2 lab def countorig_sw 16"Other Africa", modify recode countorig_sw .=17 if inlist(countorig, /// 660,28,533,44,52,535,92,136,192,531,212,214,308,312,332,388,474,500,530, /// 630,652,659,662,663,670,534,780,796,850,29,419) recode countorig_sw .=17 if inlist(countorig, 84,188,222,320,340,484,558,591,13) recode countorig_sw .=17 if inlist(countorig, /// 32,68,76,152,170,218,238,254,328,600,604,740,858,862,5) lab def countorig_sw 17"Latin America and the Caribbean", modify recode countorig_sw .=18 if inlist(countorig, 60,124,304,666,840) recode countorig_sw .=18 if countorig==1 recode countorig_sw .=18 if inlist(countorig, 36,554,574,53) lab def countorig_sw 18"Northern America and Oceania", modify recode countorig_sw .=19 if inlist(countorig, /// 4,50,64,356,364,906,462,524,586,144,34) lab def countorig_sw 19"Southern Asia", modify recode countorig_sw .=20 if inlist(countorig, /// 905,51,31,48,196,268,368,376,400,904,414,422,275,512,634,682,760,792, /// 784,887,145) lab def countorig_sw 20"Western Asia", modify recode countorig_sw .=21 if inlist(countorig, /// 96,116,360,418,458,104,608,702,764,626,704,35) lab def countorig_sw 21"South Eastern Asia", modify recode countorig_sw .=22 if inlist(countorig, 398,417,762,795,860,143) recode countorig_sw .=22 if inlist(countorig, 156,344,446,408,392,496,410,30) recode countorig_sw .=22 if countorig==142 lab def countorig_sw 22"Other Asia", modify recode countorig_sw .=23 if inlist(countorig, /// 112,100,200,203,348,616,498,642,643,703,804,810,151) recode countorig_sw .=23 if countorig==902 lab def countorig_sw 23"Eastern Europe", modify recode countorig_sw .=24 if inlist(countorig, /// 8,20,70,191,292,300,336,380,903,470,499,620,674,688,891,907,705,890,724, /// 807,39) lab def countorig_sw 24"Southern Europe", modify recode countorig_sw .=25 if inlist(countorig, /// 248,830,208,233,234,246,831,352,372,833,832,428,440,578,680,744,752,826,154) // North=68 recode countorig_sw .=25 if inlist(countorig, /// 40,56,250,276,438,442,492,528,756,155) lab def countorig_sw 25"Other Europe", modify recode countorig_sw .=26 if countorig==0 lab def countorig_sw 26"Unknown country of origin", modify recode countorig_sw .=27 if countorig==999 lab def countorig_sw 27"Unknown immigrant background", modify replace countorig_sw = -66 if country!=4 lab def countorig_sw -66"question not asked", modify lab var countorig_sw "country of origin - national classification (sweden)" lab val countorig_sw countorig_sw drop resbio parbio sccode cob cobm cobf cobmm cobmf cobfm cobff scborn mscborn /// fscborn mmscborn mfscborn fmscborn ffscborn scborn0 mscborn0 fscborn0 /// mmscborn0 mfscborn0 fmscborn0 ffscborn0 cob0 cobm0 cobf0 cobmm0 cobmf0 /// cobfm0 cobff0 foreach X of varlist generation genflag_miss genflag_nt countorig* coflag_miss coflag_nt coflag_ai { ren `X' `X'G } order generationG genflag_missG genflag_ntG countorigG /// countorig_enG countorig_geG countorig_nlG countorig_swG /// coflag_missG coflag_ntG coflag_aiG, last exit