**selecting variables to generate subset of data (immigrants only) use "C:\Dropbox\Projects\Muslims\Data\Census\census2001.dta", clear **Creating Variables **create the religion variable gen Religion = religrpa recode Religion 2/4=2 5=3 6=4 7=5 8/9=6 10/11=7 12=8 99=. label define Religion 1 "8.Catholic" 2 "7.Protestant" 3 "1.Muslim" 4 "4.Jewish" /// 5 "2.Buddhist" 6 "3.Hindu/Sikh" 7 "5.Other" 8 "6.None", replace label values Religion Religion **create the country of birth variable gen Birthplace = pobpa recode Birthplace 1/10=0 11=1 12/22=2 23=3 24/25=4 26/30=5 31/32=6 33=7 34=1 35/999=. **Arranging categories from high to low, then labelling them with numbers according to display order in R recode Birthplace 2=1 5=2 7=3 4=4 1=3 6=5 3=6 label define Birthplace 1 "6.Europe" 2 "4.East Asia" 3 "5.Americas +" /// 4 "2.South Asia" 5 "3.Africa" 6 "1.Middle East", replace label values Birthplace Birthplace **create an immigration variable, plus a immigration percent variable gen Immigrant = Birthplace recode Immigrant 1/7=1 bysort Religion: egen ImmigrantPer = mean(Immigrant) **create a different variable for the bar chart gen ImmigvNative = 0 replace ImmigvNative = ImmigrantPer if Immigrant==1 replace ImmigvNative = 1 - ImmigrantPer if Immigrant==0 **create a variable for year of arrival gen YearArriveA = yrimmiga recode YearArriveA 98/99=. **create a variable for years in country gen YearsinCountry = yrimmiga recode YearsinCountry 98/99=. replace YearsinCountry = YearsinCountry*-1+37 **create a variable for year of arrival in broader categories gen YearArriveB = yrimmig recode YearArriveB 8/9=. label define YearArriveB 1 "Pre 1961" 2 "1961-70" 3 "1971-80" /// 4 "1981-90" 5 "1991-95" 6 "1996-2001", replace label variable YearArriveB YearArriveB **create a variable for gender gen Male = sexp recode Male 1=1 2=0 label define Male 1 "Male" 0 "Female" **Removing all variables that I do not need, to keep file sizes manageable for R keep caseid agep Birthplace Religion YearArriveA YearArriveB YearsinCountry Male Immigrant ImmigrantPer ImmigvNative **Remove all cases of missing values (very few) on remaining variables keep if Religion !=. keep if Immigrant !=. save "C:\Dropbox\Projects\Muslims\Data\Census\census2001full.dta", replace outsheet using C:\Dropbox\Projects\Muslims\Data\Census\census2001full.csv, comma replace **Removing all cases of Canadian born responents keep if Birthplace !=0 **Remove all cases of missing values (very few) on remaining variables keep if Birthplace !=. keep if Religion !=. keep if YearArriveA !=. keep if YearArriveB !=. keep if Immigrant !=. save "C:\Dropbox\Projects\Muslims\Data\Census\census2001immigsonly.dta", replace outsheet using C:\Dropbox\Projects\Muslims\Data\Census\immigsonly.csv, comma replace **Subsetting Data **Catholics keep if Religion == 1 save "C:\Dropbox\Projects\Muslims\Data\Census\Catholics.dta", replace outsheet using C:\Dropbox\Projects\Muslims\Data\Census\Catholics.csv, comma replace **Protstants and Other Christian use "C:\Dropbox\Projects\Muslims\Data\Census\census2001immigsonly.dta" keep if Religion == 2 save "C:\Dropbox\Projects\Muslims\Data\Census\Protestants.dta", replace outsheet using C:\Dropbox\Projects\Muslims\Data\Census\Protestants.csv, comma replace **Muslims use "C:\Dropbox\Projects\Muslims\Data\Census\census2001immigsonly.dta" keep if Religion == 3 save "C:\Dropbox\Projects\Muslims\Data\Census\Muslims.dta", replace outsheet using C:\Dropbox\Projects\Muslims\Data\Census\Muslims.csv, comma replace ** Jews use "C:\Dropbox\Projects\Muslims\Data\Census\census2001immigsonly.dta", replace keep if Religion == 4 save "C:\Dropbox\Projects\Muslims\Data\Census\Jews.dta", replace outsheet using C:\Dropbox\Projects\Muslims\Data\Census\Jews.csv, comma replace **Buddhist use "C:\Dropbox\Projects\Muslims\Data\Census\census2001immigsonly.dta", replace keep if Religion == 5 save "C:\Dropbox\Projects\Muslims\Data\Census\Buddhist.dta", replace outsheet using C:\Dropbox\Projects\Muslims\Data\Census\Buddhist.csv, comma replace **Hindu/Sikhs use "C:\Dropbox\Projects\Muslims\Data\Census\census2001immigsonly.dta", replace keep if Religion == 6 save "C:\Dropbox\Projects\Muslims\Data\Census\HinduSikh.dta", replace outsheet using C:\Dropbox\Projects\Muslims\Data\Census\HinduSikh.csv, comma replace **Other (Non-Christian) use "C:\Dropbox\Projects\Muslims\Data\Census\census2001immigsonly.dta", replace keep if Religion == 7 save "C:\Dropbox\Projects\Muslims\Data\Census\Other.dta", replace outsheet using C:\Dropbox\Projects\Muslims\Data\Census\Other.csv, comma replace **No Religion use "C:\Dropbox\Projects\Muslims\Data\Census\census2001immigsonly.dta", replace keep if Religion == 8 save "C:\Dropbox\Projects\Muslims\Data\Census\None.dta", replace outsheet using C:\Dropbox\Projects\Muslims\Data\Census\None.csv, comma replace *****IPSOS Data clear all set mem 500m use "C:\Dropbox\Projects\Muslims\Data\Ipsos\ipsos2006.dta", clear gen Year = 2006 gen Male = pmgender recode Male 2=0 gen Vismin = . gen Religion = q27 recode Religion 5/6=5 7=6 8=7 9=. *1 "Catholic" 2 "Protestant" 3 "Muslim" 4 "Jewish" 5 "Hindu/Sikh" 6 "Other" 7 "None" gen ReligImp = . gen ChurchAtt = q26 recode ChurchAtt 8=. 5/7=0 3/4=1 2=2 1=3 *0 "Less than once a month" 1 "Less than once a week" 2 "Once a week" 3 "More than Once a week" gen GodPrayers = . gen HolyBook = . gen GayMarriage = q19 recode GayMarriage 1=1 2=2 3=3 4=. gen Education = pmed recode Education 1/2=0 3=1 4=2 5=3 6=4 7=5 8=6 9=. *Education 0