Uloading
Uloading
This commit is contained in:
BIN
Chililabdata/Bang ma bien DSS_2009.doc
Normal file
BIN
Chililabdata/Bang ma bien DSS_2009.doc
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/1-Thuyet minh de tai.doc
Normal file
BIN
Chililabdata/Bao cao/1-Thuyet minh de tai.doc
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/2-1-Bien ban lam sach so lieu.docx
Normal file
BIN
Chililabdata/Bao cao/2-1-Bien ban lam sach so lieu.docx
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/2-2-Gop y CG xay dung bo so lieu.docx
Normal file
BIN
Chililabdata/Bao cao/2-2-Gop y CG xay dung bo so lieu.docx
Normal file
Binary file not shown.
Binary file not shown.
BIN
Chililabdata/Bao cao/3-2-Ket qua phan tich so lieu.docx
Normal file
BIN
Chililabdata/Bao cao/3-2-Ket qua phan tich so lieu.docx
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/5-CG gop y BC.doc
Normal file
BIN
Chililabdata/Bao cao/5-CG gop y BC.doc
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/BB duyet de cuong co so.doc
Normal file
BIN
Chililabdata/Bao cao/BB duyet de cuong co so.doc
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/Bao cao ket hon - ly hon_2511.docx
Normal file
BIN
Chililabdata/Bao cao/Bao cao ket hon - ly hon_2511.docx
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/Bao cao ket hon - ly hon_2711.docx
Normal file
BIN
Chililabdata/Bao cao/Bao cao ket hon - ly hon_2711.docx
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/Bcao ket qua.pptx
Normal file
BIN
Chililabdata/Bao cao/Bcao ket qua.pptx
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/Du tru kinh phi.xlsx
Normal file
BIN
Chililabdata/Bao cao/Du tru kinh phi.xlsx
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/Dự trù kinh phí.doc
Normal file
BIN
Chililabdata/Bao cao/Dự trù kinh phí.doc
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/Giai trinh chinh sua.docx
Normal file
BIN
Chililabdata/Bao cao/Giai trinh chinh sua.docx
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/Giay_de_nghi_thanh_toan.doc
Normal file
BIN
Chililabdata/Bao cao/Giay_de_nghi_thanh_toan.doc
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/Giấy đề nghị tạm ứng.doc
Normal file
BIN
Chililabdata/Bao cao/Giấy đề nghị tạm ứng.doc
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/Li lich khoa hoc nam 2014_Co Quyen.doc
Normal file
BIN
Chililabdata/Bao cao/Li lich khoa hoc nam 2014_Co Quyen.doc
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/My EndNote Library.enl
Normal file
BIN
Chililabdata/Bao cao/My EndNote Library.enl
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/Phieudangkydtcso_Mau1a_Ly hon.doc
Normal file
BIN
Chililabdata/Bao cao/Phieudangkydtcso_Mau1a_Ly hon.doc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Chililabdata/Bao cao/Tai lieu/Gioi thieu CHILILAB.docx
Normal file
BIN
Chililabdata/Bao cao/Tai lieu/Gioi thieu CHILILAB.docx
Normal file
Binary file not shown.
BIN
Chililabdata/Bao cao/Tai lieu/Rawdata/Data.xlsx
Normal file
BIN
Chililabdata/Bao cao/Tai lieu/Rawdata/Data.xlsx
Normal file
Binary file not shown.
Binary file not shown.
BIN
Chililabdata/Bao cao/bieu do.xlsx
Normal file
BIN
Chililabdata/Bao cao/bieu do.xlsx
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Chililabdata/Bao cao/ly-lich-khoa-hoc_Vu Thi Hoang Lan.doc
Normal file
BIN
Chililabdata/Bao cao/ly-lich-khoa-hoc_Vu Thi Hoang Lan.doc
Normal file
Binary file not shown.
50
Chililabdata/CreateMenu.do
Normal file
50
Chililabdata/CreateMenu.do
Normal file
@@ -0,0 +1,50 @@
|
||||
window menu clear
|
||||
window menu append submenu "stUser" "&Chililab"
|
||||
window menu append submenu "Chililab" "Data"
|
||||
window menu append item "Data" "Get data from server" "db sqldata"
|
||||
window menu append item "Data" "Create last visit records" "do e:\chililabdata\lastobservation.do"
|
||||
window menu append item "Data" "Create cross working file" "db crossdata"
|
||||
|
||||
window menu append submenu "Chililab" "Demographics"
|
||||
window menu append submenu "Demographics" "Social-Economic Data"
|
||||
window menu append item "Social-Economic Data" "Economic by Quintile (longitudinal data)" "db tft"
|
||||
window menu append item "Social-Economic Data" "Education" "db tft"
|
||||
window menu append item "Social-Economic Data" "Occupation" "db tft"
|
||||
window menu append item "Social-Economic Data" "Ethnicity" "db tft"
|
||||
window menu append item "Social-Economic Data" "Marital status" "db tft"
|
||||
|
||||
window menu append item "Demographics" "Population Pyramid" "db poppyramid"
|
||||
window menu append item "Demographics" "Calculate Person Years" "db personyears"
|
||||
|
||||
window menu append submenu "Demographics" "Fertility"
|
||||
window menu append submenu "Demographics" "Mortality"
|
||||
window menu append submenu "Demographics" "Migration"
|
||||
window menu append submenu "Migration" "In Migration"
|
||||
window menu append submenu "Migration" "Out Migration"
|
||||
window menu append submenu "Migration" "Gross Migration"
|
||||
window menu append item "Demographics" "Population Grow Rate" "db poppyramid"
|
||||
|
||||
window menu append item "Fertility" "Fertility Rate (TFR)" "db tft"
|
||||
window menu append item "Fertility" "Crude Birth Rate (CBR)" "db cbr"
|
||||
window menu append item "Fertility" "Age-Specific Fertility rates(ASFR)" "db asfr"
|
||||
|
||||
window menu append item "Mortality" "Neonatal Mortality Rate" "db cdr"
|
||||
window menu append item "Mortality" "Infant Mortality Rate (IMR)" "db cdr"
|
||||
window menu append item "Mortality" "Crude Death Rate (CDR)" "db cdr"
|
||||
window menu append item "Mortality" "Age Specific Death Rate " "db cdr"
|
||||
window menu append item "Mortality" "Sex Specific Mortality Rate " "db cdr"
|
||||
window menu append item "Mortality" "Under 5 Mortality Rate/ Childhood Mortality (U5MR))" "db cdr"
|
||||
window menu append item "Mortality" "Cause of Death" "db cdr"
|
||||
window menu append item "Mortality" "Maternal mortality rate" "db cdr"
|
||||
window menu append item "Mortality" "Life Tables" "db cdr"
|
||||
window menu append item "Mortality" "Life Tables" "db cdr"
|
||||
|
||||
window menu append item "In Migration" "In Migration by sex" "db inmigration"
|
||||
window menu append item "In Migration" "In Migration by age" "db inmigration"
|
||||
|
||||
window menu append item "Out Migration" "Out Migration by sex" "db outmigration"
|
||||
window menu append item "Out Migration" "Out Migration by age" "db outmigration"
|
||||
|
||||
window menu append item "Gross Migration" "Gross Migration by sex" "db communelist"
|
||||
window menu append item "Gross Migration" "Gross Migration by age" "db communelist"
|
||||
window menu refresh
|
81
Chililabdata/CrudeBirthRate.do
Normal file
81
Chililabdata/CrudeBirthRate.do
Normal file
@@ -0,0 +1,81 @@
|
||||
cd e:\chililabdata
|
||||
clear all
|
||||
do pdo1
|
||||
global refdate = $endTime
|
||||
do ..\GenCrossEducation
|
||||
do ..\GenCrossOccupation
|
||||
use individual, clear
|
||||
sort individid
|
||||
save, replace
|
||||
use observation
|
||||
sort observeid
|
||||
save observation, replace
|
||||
use birth
|
||||
drop if bth_date < $startTime
|
||||
drop if bth_date > $endTime
|
||||
sort individid
|
||||
merge individid using individual, nokeep keep (motherid gender)
|
||||
rename gender cgender
|
||||
keep if _merge==3
|
||||
save $savefolder\allbirths$suffix, replace
|
||||
drop _merge
|
||||
rename individid childid
|
||||
rename motherid individid
|
||||
sort individid
|
||||
drop if individid ==""
|
||||
merge individid using individual, nokeep keep(birthdate )
|
||||
drop if _merge == 2
|
||||
gen age = (bth_date - birthdate)/365.25
|
||||
replace age = floor(age)
|
||||
drop _merge
|
||||
sort observeid
|
||||
merge observeid using observation
|
||||
drop if _merge!=3
|
||||
drop _merge
|
||||
gen communeid = substr(locationid, 1,2)
|
||||
sort individid
|
||||
gen refquarter = qofd(bth_date)
|
||||
tostring refquarter, generate (key)
|
||||
replace key = individid + key
|
||||
sort key
|
||||
merge key using crosseducationtemp, nokeep keep (eduid)
|
||||
drop _merge
|
||||
sort key
|
||||
merge key using crossoccupationtemp, nokeep keep (occupationid)
|
||||
drop if _merge==2
|
||||
gen area=1
|
||||
replace area=2 if (communeid=="02")
|
||||
replace area=2 if (communeid=="04")
|
||||
replace area=2 if (communeid=="05")
|
||||
replace area=2 if (communeid=="07")
|
||||
drop key
|
||||
recode age (min/0=1 "<1") (1/4=2 "1-4") (5/9=3 "5-9")(10/14=4 "10-14") (15/19=5 "15-19") (20/24=6 "20-24") (25/29=7 "25-29") (30/34=8 "30-34") (35/39=9 "35-39") (40/44=10 "40-44") (45/49=11 "45-49")(50/54=12 "50-54") (55/59=13 "55-59") (60/64=14 "60-64") (65/69=15 "65-69") (70/74=16 "70-74") (75/79=17 "75-79") (80/max=18 ">=80") , gen (agegrp)
|
||||
save $savefolder\birthsFullwithmother$suffix, replace
|
||||
gen Births =1
|
||||
collapse (sum) Births, by(communeid agegrp age )
|
||||
save $savefolder\Birthsby_commune_age$suffix, replace
|
||||
collapse (sum) Births, by(communeid agegrp )
|
||||
save $savefolder\birthsby_commune_agegrp$suffix, replace
|
||||
collapse (sum) Births, by(agegrp )
|
||||
save $savefolder\birthsby_agegrp$suffix, replace
|
||||
use $savefolder\birthsFullwithmother$suffix
|
||||
gen Births =1
|
||||
collapse (sum) Births, by(area agegrp age )
|
||||
save $savefolder\Birthsby_area_age$suffix, replace
|
||||
collapse (sum) Births, by(area agegrp )
|
||||
save $savefolder\birthsby_area_agegrp$suffix, replace
|
||||
use $savefolder\birthsFullwithmother$suffix
|
||||
gen Births =1
|
||||
collapse (sum) Births, by(area communeid eduid )
|
||||
save $savefolder\Birthsby_commune_edu$suffix, replace
|
||||
collapse (sum) Births, by(area eduid )
|
||||
save $savefolder\birthsby_area_edu$suffix, replace
|
||||
|
||||
use $savefolder\birthsFullwithmother$suffix
|
||||
gen Births =1
|
||||
collapse (sum) Births, by(area communeid occupationid )
|
||||
save $savefolder\Birthsby_commune_occupation$suffix, replace
|
||||
collapse (sum) Births, by(area occupationid )
|
||||
save $savefolder\birthsby_area_occupation$suffix, replace
|
||||
|
||||
cd e:\chililabdata
|
98
Chililabdata/CrudeDeathRate.do
Normal file
98
Chililabdata/CrudeDeathRate.do
Normal file
@@ -0,0 +1,98 @@
|
||||
cd e:\chililabdata
|
||||
clear all
|
||||
global startTime = mdy(12,31,2003)
|
||||
global endTime = mdy(12,31,2010)
|
||||
set mem 200M
|
||||
do pdo1
|
||||
global refdate = $endTime
|
||||
do ..\GenCrossEducation
|
||||
do ..\GenCrossOccupation
|
||||
do ..\GenMaritalstatus
|
||||
use individual, clear
|
||||
sort individid
|
||||
save, replace
|
||||
use location
|
||||
sort locationid
|
||||
save, replace
|
||||
use observation
|
||||
sort observeid
|
||||
save observation, replace
|
||||
use death
|
||||
drop if dth_date < $startTime
|
||||
drop if dth_date > $endTime
|
||||
sort individid
|
||||
merge individid using individual, nokeep keep (birthdate gender motherid fatherid )
|
||||
rename birthdate bod
|
||||
drop if _merge !=3
|
||||
drop _merge
|
||||
replace fatherid = "00000000000" if strlen(fatherid) !=11
|
||||
replace motherid = "00000000000" if strlen(motherid) !=11
|
||||
gen age = (dth_date - bod)/365.25
|
||||
replace age = floor(age)
|
||||
sort observeid
|
||||
merge observeid using observation
|
||||
drop if _merge!=3
|
||||
drop _merge
|
||||
gen communeid = substr(locationid, 1,2)
|
||||
sort communeid
|
||||
gen area=1
|
||||
replace area=2 if (communeid=="02")
|
||||
replace area=2 if (communeid=="04")
|
||||
replace area=2 if (communeid=="05")
|
||||
replace area=2 if (communeid=="07")
|
||||
sort locationid
|
||||
merge locationid using location,nokeep keep (address)
|
||||
drop _merge
|
||||
sort individid
|
||||
gen refquarter = qofd(dth_date)
|
||||
tostring refquarter, generate (qkey)
|
||||
gen key = individid + qkey
|
||||
sort key
|
||||
merge key using crosseducationtemp, nokeep keep(eduid)
|
||||
drop if _merge==2
|
||||
drop _merge
|
||||
sort key
|
||||
merge key using crossoccupationtemp, nokeep keep(occupationid)
|
||||
drop if _merge==2
|
||||
drop _merge
|
||||
sort key
|
||||
merge key using crossmarstatustemp, nokeep keep (marstatusid)
|
||||
drop if _merge==2
|
||||
drop _merge
|
||||
|
||||
replace key = fatherid + qkey
|
||||
sort key
|
||||
merge key using crosseducationtemp, nokeep keep(feduid)
|
||||
drop if _merge==2
|
||||
drop _merge
|
||||
sort key
|
||||
merge key using crossoccupationtemp, nokeep keep (foccupationid)
|
||||
drop if _merge==2
|
||||
drop _merge
|
||||
|
||||
replace key = motherid + qkey
|
||||
sort key
|
||||
merge key using crosseducationtemp, nokeep keep(meduid)
|
||||
drop if _merge==2
|
||||
drop _merge
|
||||
sort key
|
||||
merge key using crossoccupationtemp, nokeep keep(moccupationid)
|
||||
drop if _merge==2
|
||||
drop _merge
|
||||
save $savefolder\alldeath$suffix, replace
|
||||
gen MDeaths =0
|
||||
gen FDeaths =0
|
||||
replace MDeaths =1 if gender =="1"
|
||||
replace FDeaths =1 if gender =="2"
|
||||
collapse (sum) MDeaths FDeaths, by(communeid age )
|
||||
save $savefolder\deathby_commune_age$suffix, replace
|
||||
recode age (min/0=1 "<1") (1/4=2 "1-4") (5/9=3 "5-9")(10/14=4 "10-14") (15/19=5 "15-19") (20/24=6 "20-24") (25/29=7 "25-29") (30/34=8 "30-34") (35/39=9 "35-39") (40/44=10 "40-44") (45/49=11 "45-49")(50/54=12 "50-54") (55/59=13 "55-59") (60/64=14 "60-64") (65/69=15 "65-69") (70/74=16 "70-74") (75/79=17 "75-79") (80/max=18 ">=80") , gen (agegrp)
|
||||
collapse (sum) MDeaths FDeaths, by(communeid agegrp )
|
||||
save $savefolder\deathby_commune_agegrp$suffix, replace
|
||||
|
||||
collapse (sum) MDeaths FDeaths, by(agegrp )
|
||||
save $savefolder\deathby_agegrp$suffix, replace
|
||||
|
||||
|
||||
|
||||
cd e:\chililabdata
|
20
Chililabdata/GenASFR.do
Normal file
20
Chililabdata/GenASFR.do
Normal file
@@ -0,0 +1,20 @@
|
||||
clear all
|
||||
set memory 200M
|
||||
global year =2011
|
||||
global communeid = 0
|
||||
cd e:\chililabdata
|
||||
do genWomenBirths
|
||||
cd e:\chililabdata
|
||||
do genWomenInYear
|
||||
save WomenInYear, replace
|
||||
cd e:\chililabdata\data\birth
|
||||
use d:\chililabdata\data\cross\womeninyear
|
||||
merge agegrp using womenbirthyear
|
||||
drop if _merge == 2
|
||||
drop _merge
|
||||
gen asfr = births/women
|
||||
save asfr$year, replace
|
||||
|
||||
|
||||
|
||||
|
109
Chililabdata/GenAllBirth.do
Normal file
109
Chililabdata/GenAllBirth.do
Normal file
@@ -0,0 +1,109 @@
|
||||
clear all
|
||||
set mem 1000M
|
||||
cd c:\chililabdata\data
|
||||
use individual
|
||||
sort individid
|
||||
save individual, replace
|
||||
use observation
|
||||
sort observeid
|
||||
save observation, replace
|
||||
use birth
|
||||
gen year = year(bth_date)
|
||||
sort observeid
|
||||
merge observeid using observation
|
||||
gen communeid = substr(locationid, 1,2)
|
||||
drop if _merge !=3
|
||||
drop _merge
|
||||
sort individid
|
||||
merge individid using individual
|
||||
drop if _merge !=3
|
||||
drop _merge
|
||||
gen quarterdate = qofd(bth_date)
|
||||
tostring quarterdate, gen(quarter)
|
||||
drop fatheridGuid motheridGuid socialgpidGuid observeidGuid obs_field_wrkr obs_data_clerk obs_responsor appround eventid individidGuid observeid obs_round obs_entry_date obs_de_date obs_status_dat quarterdate
|
||||
rename bornid childbornid
|
||||
gen key = motherid + quarter
|
||||
sort key
|
||||
save birth/allbirths, replace
|
||||
keep key
|
||||
sort key
|
||||
merge key using crosseducationtemp, keep(meduid)
|
||||
|
||||
keep if _merge !=2
|
||||
drop _merge
|
||||
sort key
|
||||
merge key using birth/allbirths
|
||||
|
||||
drop _merge
|
||||
replace key = fatherid + quarter
|
||||
sort key
|
||||
save birth/allbirths, replace
|
||||
keep key
|
||||
sort key
|
||||
|
||||
merge key using crosseducationtemp, keep(feduid)
|
||||
keep if _merge !=2
|
||||
drop _merge
|
||||
sort key
|
||||
merge key using birth/allbirths
|
||||
drop _merge
|
||||
replace key = motherid + quarter
|
||||
sort key
|
||||
save birth\allbirths, replace
|
||||
|
||||
keep key
|
||||
sort key
|
||||
merge key using crossoccupationtemp, keep(moccupationid)
|
||||
keep if _merge !=2
|
||||
drop _merge
|
||||
sort key
|
||||
merge key using birth/allbirths
|
||||
drop _merge
|
||||
replace key = fatherid + quarter
|
||||
sort key
|
||||
save birth\allbirths, replace
|
||||
keep key
|
||||
sort key
|
||||
|
||||
merge key using crossoccupationtemp, keep(foccupationid)
|
||||
keep if _merge !=2
|
||||
drop _merge
|
||||
sort key
|
||||
merge key using birth/allbirths
|
||||
drop _merge
|
||||
replace key = socialgpid + quarter
|
||||
sort key
|
||||
save birth/allbirths, replace
|
||||
|
||||
keep key
|
||||
sort key
|
||||
merge key using householdinfortemp
|
||||
keep if _merge !=2
|
||||
drop _merge
|
||||
sort key
|
||||
merge key using birth/allbirths
|
||||
drop _merge
|
||||
sort key
|
||||
drop birthdate
|
||||
rename individid childid
|
||||
rename fatherid individid
|
||||
sort individid
|
||||
merge individid using individual, keep(birthdate bornid)
|
||||
keep if _merge !=2
|
||||
rename birthdate fbirthdate
|
||||
rename bornid fbornid
|
||||
rename individid fatherid
|
||||
rename motherid individid
|
||||
drop _merge
|
||||
sort individid
|
||||
merge individid using individual, keep(birthdate bornid)
|
||||
keep if _merge !=2
|
||||
rename birthdate mbirthdate
|
||||
rename bornid mbornid
|
||||
rename individid motherid
|
||||
rename childid individid
|
||||
drop key hhinforid observeid responsorID entryDate fieldWrkr dataClerk deDate statusDat obs_de_date refdate period p quarterdate refquarter maxobs_de_date quarter _merge
|
||||
|
||||
save birth/allbirths, replace
|
||||
|
||||
cd c:\chililabdata
|
47
Chililabdata/GenBirthsRel.do
Normal file
47
Chililabdata/GenBirthsRel.do
Normal file
@@ -0,0 +1,47 @@
|
||||
clear all
|
||||
set mem 1000M
|
||||
cd e:\chililabdata\data
|
||||
use individual
|
||||
sort individid
|
||||
replace motherid = trim(motherid)
|
||||
drop if strlen(motherid) < 11
|
||||
sort motherid
|
||||
egen maxchild = count(birthdate), by (motherid)
|
||||
drop if maxchild < 2
|
||||
sort motherid birthdate
|
||||
by motherid: gen no=_n
|
||||
tostring no, gen(no1)
|
||||
gen key = motherid + no1
|
||||
drop no1
|
||||
sort key
|
||||
save person1, replace
|
||||
|
||||
replace no=no +1
|
||||
tostring no, gen(no1)
|
||||
replace key = motherid + no1
|
||||
keep individid birthdate gender key
|
||||
rename individid prevchildid
|
||||
rename birthdate prevbirthdate
|
||||
rename gender prevgender
|
||||
sort key
|
||||
save person2, replace
|
||||
brow
|
||||
|
||||
use person1
|
||||
merge key using person2
|
||||
keep if _merge ==3
|
||||
keep individid prevchildid prevbirthdate prevgender
|
||||
|
||||
sort individid
|
||||
duplicates drop individid, force
|
||||
save personRel, replace
|
||||
use birth\allbirths
|
||||
|
||||
sort individid
|
||||
|
||||
merge individid using personRel
|
||||
keep if _merge!=2
|
||||
save, replace
|
||||
|
||||
cd e:\chililabdata
|
||||
|
44
Chililabdata/GenCrossEducation.do
Normal file
44
Chililabdata/GenCrossEducation.do
Normal file
@@ -0,0 +1,44 @@
|
||||
use observation
|
||||
sort observeid
|
||||
save observation, replace
|
||||
use education
|
||||
keep individid eduid edu_sobserveid
|
||||
rename edu_sobserveid observeid
|
||||
sort observeid
|
||||
merge observeid using observation, nokeep keep (obs_de_date)
|
||||
gen refdate = $refdate + 180
|
||||
|
||||
drop if refdate < obs_de_date
|
||||
gen period = qofd(refdate )-qofd(obs_de_date ) +1
|
||||
expand period
|
||||
sort individid obs_de_date
|
||||
by individid obs_de_date: gen p= _n-1
|
||||
gen quarterdate = qofd(obs_de_date) + p
|
||||
gen refquarter = qofd(refdate )
|
||||
sort individid quarterdate
|
||||
egen maxobs_de_date = max(obs_de_date), by(individid quarterdate)
|
||||
keep if obs_de_date == maxobs_de_date
|
||||
sort individid
|
||||
gen fatherid = individid
|
||||
gen motherid = individid
|
||||
gen partnerid = individid
|
||||
gen feduid = eduid
|
||||
gen meduid = eduid
|
||||
gen peduid= eduid
|
||||
tostring quarterdate, generate(key)
|
||||
replace key = individid + key
|
||||
duplicates drop key, force
|
||||
drop _merge
|
||||
sort key
|
||||
save crosseducationtemp, replace
|
||||
keep if refquarter == quarterdate
|
||||
format refdate %td
|
||||
keep individid fatherid motherid partnerid eduid feduid meduid peduid refdate obs_de_date observeid
|
||||
duplicates drop individid, force
|
||||
sort individid
|
||||
|
||||
save cross\crosseducation, replace
|
||||
keep partnerid peduid
|
||||
sort partnerid
|
||||
save cross\crosspeducation, replace
|
||||
|
13
Chililabdata/GenCrossHouseResidency.do
Normal file
13
Chililabdata/GenCrossHouseResidency.do
Normal file
@@ -0,0 +1,13 @@
|
||||
use houseres
|
||||
sort socialgpid
|
||||
egen counter = count(episodeid), by(socialgpid)
|
||||
drop if (res_edate != . & res_edate < $refdate )
|
||||
drop if (res_sdate != . & res_sdate > $refdate )
|
||||
gen refdate = $refdate
|
||||
keep socialgpid locationid
|
||||
sort socialgpid
|
||||
|
||||
duplicates drop socialgpid, force
|
||||
sort socialgpid
|
||||
save cross\crosshouseresidency, replace
|
||||
|
35
Chililabdata/GenCrossHouseholdinfo.do
Normal file
35
Chililabdata/GenCrossHouseholdinfo.do
Normal file
@@ -0,0 +1,35 @@
|
||||
use observation
|
||||
sort observeid
|
||||
save observation, replace
|
||||
use householdInfo
|
||||
drop if socialgpid == ""
|
||||
sort observeid
|
||||
merge observeid using observation, nokeep keep (obs_de_date)
|
||||
gen refdate = $refdate + 180
|
||||
drop if refdate < obs_de_date
|
||||
gen period = qofd(refdate )-qofd(obs_de_date ) +1
|
||||
expand period
|
||||
sort socialgpid obs_de_date
|
||||
by socialgpid obs_de_date: gen p= _n-1
|
||||
gen quarterdate = qofd(obs_de_date) + p
|
||||
gen refquarter = qofd(refdate )
|
||||
sort socialgpid quarterdate
|
||||
egen maxobs_de_date = max(obs_de_date), by(socialgpid quarterdate)
|
||||
keep if obs_de_date == maxobs_de_date
|
||||
tostring quarterdate, gen(key)
|
||||
replace key = socialgpid + key
|
||||
sort key
|
||||
save householdinfortemp, replace
|
||||
keep if refquarter == quarterdate
|
||||
format refdate %td
|
||||
drop _merge period quarterdate refquarter hhinforid observeid p
|
||||
duplicates drop socialgpid, force
|
||||
sort socialgpid
|
||||
save cross\crosshouseholdinfo, replace
|
||||
global refmonth = month( $refdate + 180)
|
||||
global refyear = year( $refdate + 180)
|
||||
save cross\crosshouseholdinfo$refmonth$refyear, replace
|
||||
use cross\crosshouseresidency
|
||||
merge socialgpid using cross\crosshouseholdinfo
|
||||
keep if _merge ==3
|
||||
save cross\crossresidencyhouseholdinfo, replace
|
32
Chililabdata/GenCrossMedInsurance.do
Normal file
32
Chililabdata/GenCrossMedInsurance.do
Normal file
@@ -0,0 +1,32 @@
|
||||
use observation
|
||||
sort observeid
|
||||
save observation, replace
|
||||
use medinsurance
|
||||
keep individid hinsid hin_sobserveid
|
||||
rename hin_sobserveid observeid
|
||||
sort observeid
|
||||
merge observeid using observation, nokeep keep (obs_de_date)
|
||||
gen refdate = $refdate + 180
|
||||
drop if refdate < obs_de_date
|
||||
gen period = qofd(refdate )-qofd(obs_de_date ) +1
|
||||
expand period
|
||||
sort individid obs_de_date
|
||||
by individid obs_de_date: gen p= _n-1
|
||||
gen quarterdate = qofd(obs_de_date) + p
|
||||
gen refquarter = qofd(refdate )
|
||||
sort individid quarterdate
|
||||
egen maxobs_de_date = max(obs_de_date), by(individid quarterdate)
|
||||
keep if obs_de_date == maxobs_de_date
|
||||
sort individid
|
||||
tostring quarterdate, generate(key)
|
||||
replace key = individid + key
|
||||
duplicates drop key, force
|
||||
drop _merge
|
||||
sort key
|
||||
save crossmedinsurancetemp, replace
|
||||
keep if refquarter == quarterdate
|
||||
format refdate %td
|
||||
keep individid hinsid refdate obs_de_date observeid
|
||||
duplicates drop individid, force
|
||||
sort individid
|
||||
save cross\crossmedinsurance, replace
|
41
Chililabdata/GenCrossMembership.do
Normal file
41
Chililabdata/GenCrossMembership.do
Normal file
@@ -0,0 +1,41 @@
|
||||
use individual
|
||||
sort individid
|
||||
save individual, replace
|
||||
use observation
|
||||
sort observeid
|
||||
save observation, replace
|
||||
use membership
|
||||
drop if (mem_edate != . & mem_edate < $refdate)
|
||||
drop if (mem_sdate != . & mem_sdate > $refdate)
|
||||
gen refdate = $refdate
|
||||
rename mem_sobserveid observeid
|
||||
duplicates drop individid, force
|
||||
sort observeid
|
||||
merge observeid using observation
|
||||
tab _merge
|
||||
drop if _merge!=3
|
||||
drop _merge
|
||||
rename locationid sociallocid
|
||||
keep socialgpid individid sociallocid refdate
|
||||
sort individid
|
||||
format refdate %td
|
||||
merge individid using individual
|
||||
tab _merge
|
||||
drop if _merge != 3
|
||||
drop _merge
|
||||
rename birthdate bod
|
||||
drop appround
|
||||
drop ind_name
|
||||
duplicates drop individid, force
|
||||
replace fatherid = "00000000000" if strlen(fatherid) !=11
|
||||
replace motherid = "00000000000" if strlen(motherid) !=11
|
||||
save cross\crossmembership, replace
|
||||
use individual
|
||||
keep individid birthdate
|
||||
rename individid fatherid
|
||||
rename birthdate fbod
|
||||
save cross\crossfbod, replace
|
||||
rename fatherid motherid
|
||||
rename fbod mbod
|
||||
save cross\crossmbod, replace
|
||||
close
|
54
Chililabdata/GenCrossOccupation.do
Normal file
54
Chililabdata/GenCrossOccupation.do
Normal file
@@ -0,0 +1,54 @@
|
||||
use observation
|
||||
sort observeid
|
||||
save observation, replace
|
||||
use occupation
|
||||
keep individid occupationid occ_sobserveid
|
||||
rename occ_sobserveid observeid
|
||||
sort observeid
|
||||
merge observeid using observation, nokeep keep (obs_de_date)
|
||||
gen refdate = $refdate + 180
|
||||
drop if refdate < obs_de_date
|
||||
gen period = qofd(refdate )-qofd(obs_de_date) +1
|
||||
expand period
|
||||
sort individid obs_de_date
|
||||
by individid obs_de_date: gen p= _n-1
|
||||
gen quarterdate = qofd(obs_de_date) + p
|
||||
gen refquarter = qofd(refdate )
|
||||
sort individid quarterdate
|
||||
egen maxobs_de_date = max(obs_de_date), by(individid quarterdate)
|
||||
keep if obs_de_date == maxobs_de_date
|
||||
sort individid
|
||||
gen fatherid =individid
|
||||
gen motherid = individid
|
||||
gen partnerid = individid
|
||||
|
||||
gen foccupationid = occupationid
|
||||
gen moccupationid = occupationid
|
||||
gen poccupationid = occupationid
|
||||
tostring quarterdate, generate(key)
|
||||
replace key = individid + key
|
||||
duplicates drop key, force
|
||||
drop _merge
|
||||
sort key
|
||||
save crossOccupationtemp, replace
|
||||
keep if refquarter == quarterdate
|
||||
format refdate %td
|
||||
keep individid fatherid motherid partnerid occupationid foccupationid moccupationid poccupationid refdate obs_de_date observeid
|
||||
duplicates drop individid, force
|
||||
sort individid
|
||||
save cross\crossoccupation, replace
|
||||
keep partnerid poccupationid refdate
|
||||
sort partnerid
|
||||
save cross\crosspoccupation, replace
|
||||
use cross\crossoccupation
|
||||
keep motherid moccupationid refdate
|
||||
sort motherid
|
||||
save cross\crossmoccupation, replace
|
||||
use cross\crossoccupation
|
||||
keep fatherid foccupationid refdate
|
||||
sort fatherid
|
||||
save cross\crossfoccupation, replace
|
||||
|
||||
|
||||
|
||||
|
36
Chililabdata/GenCrossRelatonship.do
Normal file
36
Chililabdata/GenCrossRelatonship.do
Normal file
@@ -0,0 +1,36 @@
|
||||
use relationship
|
||||
drop if (rel_edate != . & rel_edate < $refdate)
|
||||
drop if (rel_sdate != . & rel_sdate > $refdate)
|
||||
gen refdate = $refdate
|
||||
sort individid
|
||||
format refdate %td
|
||||
sort individid
|
||||
rename rel_partnerid partnerid
|
||||
rename rel_sdate marrieddate
|
||||
drop if strlen(partnerid) !=11
|
||||
keep individid partnerid marrieddate
|
||||
duplicates drop individid, force
|
||||
save cross\crossrelationship, replace
|
||||
|
||||
gen individid1 = individid
|
||||
replace individid = partnerid
|
||||
replace partnerid = individid1
|
||||
drop individid1
|
||||
save cross\crossrelationship1, replace
|
||||
|
||||
use cross\crossrelationship
|
||||
append using cross\crossrelationship1
|
||||
sort partnerid
|
||||
duplicates drop individid, force
|
||||
save cross\crossrelationship, replace
|
||||
merge partnerid using cross\crosspeducation
|
||||
drop if _merge ==2
|
||||
drop _merge
|
||||
sort partnerid
|
||||
merge partnerid using cross\crosspoccupation
|
||||
drop if _merge ==2
|
||||
drop _merge
|
||||
drop refdate
|
||||
sort individid
|
||||
save cross\crossrelationship, replace
|
||||
|
4
Chililabdata/GenCrossReligionInfo.do
Normal file
4
Chililabdata/GenCrossReligionInfo.do
Normal file
@@ -0,0 +1,4 @@
|
||||
use religion
|
||||
sort individ
|
||||
duplicates drop individ, force
|
||||
save cross\crossreligioninfo, replace
|
11
Chililabdata/GenCrossResidency.do
Normal file
11
Chililabdata/GenCrossResidency.do
Normal file
@@ -0,0 +1,11 @@
|
||||
use individres
|
||||
drop if (res_edate != . & res_edate < $refdate)
|
||||
drop if (res_sdate != . & res_sdate > $refdate)
|
||||
gen refdate = $refdate
|
||||
keep individid locationid
|
||||
sort individid
|
||||
|
||||
duplicates drop individid, force
|
||||
sort individid
|
||||
save cross\crossresidency, replace
|
||||
|
26
Chililabdata/GenLongBirth.do
Normal file
26
Chililabdata/GenLongBirth.do
Normal file
@@ -0,0 +1,26 @@
|
||||
clear
|
||||
|
||||
cd e:\chililabdata\data
|
||||
use individual
|
||||
sort individid
|
||||
save, replace
|
||||
use birth
|
||||
sort individid
|
||||
duplicates drop individid, force
|
||||
merge 1:1 individid using individual, keepusing(gender motherid)
|
||||
rename gender sex
|
||||
rename individid childid
|
||||
rename motherid individid
|
||||
gen socialgpid = substr(observeid,1,9)
|
||||
replace bth_date= bth_date/86400000
|
||||
format bth_date %td
|
||||
gen year = year( bth_date)
|
||||
gen h = halfyear(bth_date)
|
||||
gen round = yh(year,h)-89
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) ==1
|
||||
gen socialkey = socialgpid+ rounds
|
||||
gen individkey = individid+ rounds
|
||||
drop eventid observeid individidGuid _merge h
|
||||
drop if round < 0
|
||||
save rBirths, replace
|
24
Chililabdata/GenLongDeath.do
Normal file
24
Chililabdata/GenLongDeath.do
Normal file
@@ -0,0 +1,24 @@
|
||||
clear
|
||||
cd e:\chililabdata\data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use death
|
||||
gen socialgpid = substr(observeid,1,9)
|
||||
replace dth_date=dth_date/86400000
|
||||
format dth_date %td
|
||||
gen year = year( dth_date)
|
||||
gen h = halfyear(dth_date)
|
||||
gen round = yh(year,h)-89
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) ==1
|
||||
gen socialkey = socialgpid+ rounds
|
||||
gen individkey = individid+ rounds
|
||||
drop EID h rounds eventid year individidGuid
|
||||
duplicates drop individkey, force
|
||||
sort observeid
|
||||
merge m:1 observeid using observation, keepusing(locationid)
|
||||
keep if _merge ==3
|
||||
drop observeid _merge
|
||||
drop if round < 0
|
||||
save rDeaths, replace
|
18
Chililabdata/GenLongInmigration.do
Normal file
18
Chililabdata/GenLongInmigration.do
Normal file
@@ -0,0 +1,18 @@
|
||||
clear
|
||||
cd e:\chililabdata\data
|
||||
use inmigration
|
||||
replace img_date=img_date/86400000
|
||||
format img_date %td
|
||||
gen year = year( img_date)
|
||||
drop if year < 2004
|
||||
gen h = halfyear(img_date)
|
||||
gen round = yh(year,h)-89
|
||||
drop if round > 19
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) ==1
|
||||
gen socialkey = socialgpid+ rounds
|
||||
gen individkey = individid+ rounds
|
||||
drop EID h socialgpidGuid rounds eventid observeid year
|
||||
duplicates drop individkey, force
|
||||
drop if round < 0
|
||||
save rImmigration, replace
|
28
Chililabdata/GenLongMembership.do
Normal file
28
Chililabdata/GenLongMembership.do
Normal file
@@ -0,0 +1,28 @@
|
||||
clear
|
||||
cd e:\chililabdata\data
|
||||
use membership
|
||||
sort individid
|
||||
drop if individid==""
|
||||
replace mem_sdate=mem_sdate/86400000
|
||||
rename mem_sdate sdate
|
||||
format sdate %td
|
||||
gen year = year( sdate)
|
||||
drop if year < 2004
|
||||
gen h = halfyear(sdate)
|
||||
gen round = yh(year,h)-89
|
||||
sort individid round
|
||||
duplicates drop individid round, force
|
||||
gen period = round[_n+1]-round
|
||||
replace period = 109-89 -round if individ != individid[_n+1]
|
||||
drop mem_episodeid mem_sobserveid mem_seventtype mem_eobserveid mem_edate mem_eeventtype mem_no socialgpidGuid mem_sobserveidGuid mem_eobserveidGuid h year
|
||||
expand period
|
||||
sort individid round
|
||||
by individid round: gen p=_n-1
|
||||
replace round = round+p
|
||||
drop if round > 19
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) == 1
|
||||
gen socialkeys = socialgpid + rounds
|
||||
gen individkey = individid + rounds
|
||||
drop period p
|
||||
save rMembership, replace
|
34
Chililabdata/GenLongOccupation.do
Normal file
34
Chililabdata/GenLongOccupation.do
Normal file
@@ -0,0 +1,34 @@
|
||||
clear all
|
||||
cd data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use occupation
|
||||
rename occ_sobserveid observeid
|
||||
sort observeid
|
||||
merge m:1 observeid using observation, keepusing(obs_entry_date)
|
||||
keep if _merge ==3
|
||||
gen year = year( obs_entry_date/86400000)
|
||||
drop if year < 2004
|
||||
gen h = halfyear(obs_entry_date/86400000)
|
||||
gen round = yh(year,h)
|
||||
sort individid round
|
||||
gen period = round[_n+1]-round
|
||||
replace period = 109-round if individid!=individid[_n+1]
|
||||
expand period
|
||||
replace round = round-89
|
||||
sort individid round
|
||||
by individid round: gen p= _n-1
|
||||
replace round = round + p
|
||||
drop if round > 19
|
||||
drop h period p _merge obs_entry_date
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) == 1
|
||||
gen individkey = individid + rounds
|
||||
sort individkey
|
||||
duplicates drop individkey, force
|
||||
drop occ_episodeid observeid occ_eobserveid
|
||||
save rOccupation, replace
|
||||
|
||||
|
||||
|
17
Chililabdata/GenLongOutmigration.do
Normal file
17
Chililabdata/GenLongOutmigration.do
Normal file
@@ -0,0 +1,17 @@
|
||||
clear
|
||||
cd e:\chililabdata\data
|
||||
use outmigration
|
||||
replace out_date=out_date/86400000
|
||||
format out_date %td
|
||||
gen year = year( out_date)
|
||||
drop if year < 2004
|
||||
gen round = year-2004
|
||||
drop if round > 10
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) ==1
|
||||
gen socialkey = socialgpid+ rounds
|
||||
gen individkey = individid+ rounds
|
||||
drop EID socialgpidGuid eventid observeid year
|
||||
duplicates drop individkey, force
|
||||
drop if round < 0
|
||||
save rYOutmigration, replace
|
31
Chililabdata/GenLongPregnance.do
Normal file
31
Chililabdata/GenLongPregnance.do
Normal file
@@ -0,0 +1,31 @@
|
||||
clear
|
||||
cd e:\chililabdata\data
|
||||
use individual
|
||||
sort individid
|
||||
save, replace
|
||||
use pregnance
|
||||
sort individid
|
||||
merge m:1 individid using individual, keepusing(birthdate)
|
||||
drop if _merge!=3
|
||||
drop _merge
|
||||
gen socialgpid = substr(sobserveid,1,9)
|
||||
replace preg_sdate= preg_sdate/86400000
|
||||
rename preg_sdate sdate
|
||||
replace preg_edate= preg_edate/86400000
|
||||
rename preg_edate edate
|
||||
replace birthdate= birthdate/86400000
|
||||
rename birthdate bod
|
||||
format bod %td
|
||||
format sdate %td
|
||||
format edate %td
|
||||
gen year = year( sdate)
|
||||
gen h = halfyear(sdate)
|
||||
gen round = yh(year,h)-89
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) ==1
|
||||
gen socialkey = socialgpid+ rounds
|
||||
gen individkey = individid+ rounds
|
||||
drop eventid sobserveid fatherid fatheridGuid EID rounds h year
|
||||
sort individid round
|
||||
drop if round < 0
|
||||
save rPregnance, replace
|
52
Chililabdata/GenLongRes.do
Normal file
52
Chililabdata/GenLongRes.do
Normal file
@@ -0,0 +1,52 @@
|
||||
clear
|
||||
cd c:\chililabdata\data
|
||||
use individres.dta
|
||||
gen eventdate=res_sdate/86400000
|
||||
keep individid res_seventtype eventdate
|
||||
rename res_seventtype eventtype
|
||||
gen year = year(eventdate)
|
||||
replace year = 2004 if year <2004
|
||||
save statevent, replace
|
||||
|
||||
use individres.dta
|
||||
gen eventdate=res_edate/86400000 if res_edate!=.
|
||||
keep individid res_eeventtype eventdate
|
||||
rename res_eeventtype eventtype
|
||||
gen year = year(eventdate)
|
||||
replace year = 2013 if year > 2013
|
||||
replace year = 2013 if eventdate==.
|
||||
replace year = 2004 if year <2004
|
||||
replace eventtype = "CONT" if eventdate==.
|
||||
replace eventdate = mdy(12,31,2013) if eventdate==.
|
||||
append using statevent
|
||||
duplicates drop individ eventtype year, force
|
||||
sort individid year
|
||||
|
||||
gen period = year[_n+1]-year if individ == individid[_n+1]
|
||||
|
||||
expand period if eventtype =="ENU" | eventtype =="IMG" | eventtype =="BTH"
|
||||
sort individid year
|
||||
by individid year: gen p=_n-1
|
||||
replace year = year + p
|
||||
keep if eventtype =="BTH" | eventtype =="ENU" | eventtype =="IMG" | eventtype =="ENT" | eventtype =="CONT"
|
||||
merge m:1 individ using individual, keepusing(birthdate gender)
|
||||
keep if _merge ==3
|
||||
drop _merge
|
||||
destring gender, replace
|
||||
rename gender sex
|
||||
replace birthdate=birthdate/86400000
|
||||
|
||||
format %td eventdate
|
||||
format %td birthdate
|
||||
|
||||
gen birthyear = year(birthdate)
|
||||
|
||||
gen age = year - birthyear
|
||||
drop if age < 0
|
||||
drop if year < 2004
|
||||
drop if year > 2013
|
||||
drop if age > 100
|
||||
d
|
||||
save c:\chililabdata\data\death\longindivid, replace
|
||||
drop if age < 60
|
||||
save c:\chililabdata\data\death\60longindivid, replace
|
17
Chililabdata/GenLongYInmigration.do
Normal file
17
Chililabdata/GenLongYInmigration.do
Normal file
@@ -0,0 +1,17 @@
|
||||
clear
|
||||
cd e:\chililabdata\data
|
||||
use inmigration
|
||||
replace img_date=img_date/86400000
|
||||
format img_date %td
|
||||
gen year = year( img_date)
|
||||
drop if year < 2004
|
||||
gen round = year-2004
|
||||
drop if round > 10
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) ==1
|
||||
gen socialkey = socialgpid+ rounds
|
||||
gen individkey = individid+ rounds
|
||||
drop EID socialgpidGuid rounds eventid observeid
|
||||
duplicates drop individkey, force
|
||||
drop if round < 0
|
||||
save rYImmigration, replace
|
29
Chililabdata/GenLongYMembership.do
Normal file
29
Chililabdata/GenLongYMembership.do
Normal file
@@ -0,0 +1,29 @@
|
||||
clear
|
||||
cd e:\chililabdata\data
|
||||
use membership
|
||||
sort individid
|
||||
drop if individid==""
|
||||
replace mem_sdate=mem_sdate/86400000
|
||||
rename mem_sdate sdate
|
||||
format sdate %td
|
||||
gen year = year( sdate)
|
||||
drop if year < 2004
|
||||
gen round = year
|
||||
sort individid round
|
||||
duplicates drop individid round, force
|
||||
|
||||
gen period = round[_n+1]-round
|
||||
replace period = 2014-round if individ != individid[_n+1]
|
||||
drop mem_episodeid mem_sobserveid mem_seventtype mem_eobserveid mem_edate mem_eeventtype mem_no socialgpidGuid mem_sobserveidGuid mem_eobserveidGuid year
|
||||
expand period
|
||||
replace round = round-2004
|
||||
sort individid round
|
||||
by individid round: gen p=_n-1
|
||||
replace round = round+p
|
||||
drop if round > 10
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) == 1
|
||||
gen socialkeys = socialgpid + rounds
|
||||
gen individkey = individid + rounds
|
||||
drop period p
|
||||
save rYMembership, replace
|
34
Chililabdata/GenLongYOccupation.do
Normal file
34
Chililabdata/GenLongYOccupation.do
Normal file
@@ -0,0 +1,34 @@
|
||||
clear all
|
||||
cd data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use occupation
|
||||
rename occ_sobserveid observeid
|
||||
sort observeid
|
||||
merge m:1 observeid using observation, keepusing(obs_entry_date)
|
||||
keep if _merge ==3
|
||||
gen year = year( obs_entry_date/86400000)
|
||||
drop if year < 2004
|
||||
gen round = year
|
||||
sort individid round
|
||||
duplicates drop individid round, force
|
||||
gen period = round[_n+1]-round
|
||||
replace period = 2014-round if individid!=individid[_n+1]
|
||||
expand period
|
||||
replace round = round-2004
|
||||
sort individid round
|
||||
by individid round: gen p= _n-1
|
||||
replace round = round + p
|
||||
drop if round > 10
|
||||
drop period p _merge obs_entry_date
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) == 1
|
||||
gen individkey = individid + rounds
|
||||
sort individkey
|
||||
duplicates drop individkey, force
|
||||
drop occ_episodeid observeid occ_eobserveid
|
||||
save rYOccupation, replace
|
||||
|
||||
|
||||
|
33
Chililabdata/GenMaritalstatus.do
Normal file
33
Chililabdata/GenMaritalstatus.do
Normal file
@@ -0,0 +1,33 @@
|
||||
use observation
|
||||
sort observeid
|
||||
save observation, replace
|
||||
use indmarstatus
|
||||
keep individid marstatusid mar_sobserveid
|
||||
rename mar_sobserveid observeid
|
||||
sort observeid
|
||||
merge observeid using observation, nokeep keep (obs_de_date)
|
||||
|
||||
drop if $refdate < obs_de_date
|
||||
gen period = qofd($refdate )-qofd(obs_de_date ) +1
|
||||
expand period
|
||||
sort individid obs_de_date
|
||||
by individid obs_de_date: gen p= _n-1
|
||||
gen quarterdate = qofd(obs_de_date) + p
|
||||
sort individ quarterdate
|
||||
gen refquarter = qofd($refdate )
|
||||
sort individid quarterdate
|
||||
egen maxobs_de_date = max(obs_de_date), by(individid quarterdate)
|
||||
keep if obs_de_date == maxobs_de_date
|
||||
tostring quarterdate, generate(key)
|
||||
replace key = individid + key
|
||||
duplicates drop key, force
|
||||
drop _merge
|
||||
sort key
|
||||
save crossmarstatustemp, replace
|
||||
keep if refquarter == quarterdate
|
||||
gen refdate = $refdate
|
||||
format refdate %td
|
||||
keep individid marstatusid refdate obs_de_date observeid
|
||||
duplicates drop individid, force
|
||||
sort individid
|
||||
save cross\crossmarstatus, replace
|
44
Chililabdata/GenMidYearPop.do
Normal file
44
Chililabdata/GenMidYearPop.do
Normal file
@@ -0,0 +1,44 @@
|
||||
clear all
|
||||
set memory 200M
|
||||
cd e:\chililabdata\data
|
||||
|
||||
global refdate = mdy(7,1,$year)
|
||||
use individres
|
||||
drop if (res_edate != . & res_edate < $refdate)
|
||||
drop if (res_sdate != . & res_sdate > $refdate)
|
||||
keep individid locationid
|
||||
duplicates drop individid, force
|
||||
sort individid
|
||||
save cross\crossindividres, replace
|
||||
use observation
|
||||
sort observeid
|
||||
save observation, replace
|
||||
|
||||
use membership
|
||||
drop if (mem_edate != . & mem_edate < $refdate)
|
||||
drop if (mem_sdate != . & mem_sdate > $refdate)
|
||||
duplicates drop individid, force
|
||||
rename mem_sobserveid observeid
|
||||
sort observeid
|
||||
merge observeid using observation
|
||||
tab _merge
|
||||
drop if _merge !=3
|
||||
drop _merge
|
||||
rename locationid sociallocid
|
||||
gen communeid = substr(sociallocid, 1,2)
|
||||
sort individid
|
||||
|
||||
merge individid using cross\crossindividres
|
||||
table _merge
|
||||
drop _merge
|
||||
gen isresident =0
|
||||
replace isresident =(locationid==sociallocid)
|
||||
drop if isresident == $isresident
|
||||
replace communeid="00" if $communeid ==0
|
||||
drop if communeid ! ="0$communeid"
|
||||
sort communeid
|
||||
collapse (count) midyearpop=mem_episodeid, by (communeid)
|
||||
keep communeid midyearpop
|
||||
sort communeid
|
||||
save cross\MidYearPop, replace
|
||||
cd e:\chililabdata
|
38
Chililabdata/GenOccupationTemp.do
Normal file
38
Chililabdata/GenOccupationTemp.do
Normal file
@@ -0,0 +1,38 @@
|
||||
use observation
|
||||
sort observeid
|
||||
save observation, replace
|
||||
use occupation
|
||||
keep individid occupationid occ_sobserveid
|
||||
rename occ_sobserveid observeid
|
||||
sort observeid
|
||||
merge observeid using observation, nokeep keep (obs_de_date)
|
||||
drop if $refdate < obs_de_date
|
||||
gen period = qofd($refdate )-qofd($startdate ) +1
|
||||
expand period
|
||||
sort individid obs_de_date
|
||||
by individid obs_de_date: gen p= _n-1
|
||||
gen quarterdate = qofd(obs_de_date) + p
|
||||
gen refquarter = qofd($refdate )
|
||||
sort individid quarterdate
|
||||
egen maxobs_de_date = max(obs_de_date), by(individid quarterdate)
|
||||
keep if obs_de_date == maxobs_de_date
|
||||
save crossOccupationtemp, replace
|
||||
keep if refquarter == quarterdate
|
||||
gen refdate = $refdate
|
||||
format refdate %td
|
||||
keep individid occupationid refdate obs_de_date observeid
|
||||
duplicates drop individid, force
|
||||
sort individid
|
||||
save cross\crossoccupation, replace
|
||||
rename individid fatherid
|
||||
rename occupationid foccupationid
|
||||
sort fatherid
|
||||
save cross\crossfoccupation, replace
|
||||
rename fatherid motherid
|
||||
rename foccupationid moccupationid
|
||||
sort motherid
|
||||
save cross\crossmoccupation, replace
|
||||
rename motherid partnerid
|
||||
rename moccupationid poccupationid
|
||||
sort partnerid
|
||||
save cross\crosspoccupation, replace
|
32
Chililabdata/GenPregnance.do
Normal file
32
Chililabdata/GenPregnance.do
Normal file
@@ -0,0 +1,32 @@
|
||||
clear
|
||||
|
||||
cd e:\chililabdata\data
|
||||
use individual
|
||||
sort individid
|
||||
save, replace
|
||||
use pregnance
|
||||
sort individid
|
||||
merge m:1 individid using individual, keepusing(birthdate)
|
||||
drop if _merge!=2
|
||||
drop _merge
|
||||
gen socialgpid = substr(sobserveid,1,9)
|
||||
replace preg_sdate= preg_sdate/86400000
|
||||
rename preg_sdate sdate
|
||||
replace preg_edate= preg_edate/86400000
|
||||
rename preg_edate edate
|
||||
replace birthdate= birthdate/86400000
|
||||
rename birthdate bod
|
||||
format bod %td
|
||||
format sdate %td
|
||||
format edate %td
|
||||
gen year = year( sdate)
|
||||
gen h = halfyear(sdate)
|
||||
gen round = yh(year,h)-89
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) ==1
|
||||
gen socialkey = socialgpid+ rounds
|
||||
gen individkey = individid+ rounds
|
||||
drop eventid sobserveid fatherid fatheridGuid EID
|
||||
sort individid round
|
||||
drop if round < 0
|
||||
save rPregnance, replace
|
50
Chililabdata/GenWomenBeginYear.do
Normal file
50
Chililabdata/GenWomenBeginYear.do
Normal file
@@ -0,0 +1,50 @@
|
||||
clear all
|
||||
set mem 200M
|
||||
cd e:\chililabdata\data
|
||||
use individual
|
||||
sort individid
|
||||
save individual, replace
|
||||
use observation
|
||||
sort observeid
|
||||
save observation, replace
|
||||
use individres
|
||||
drop if (res_edate != . & res_edate < $refdate)
|
||||
drop if (res_sdate != . & res_sdate > $refdate)
|
||||
sort individ
|
||||
duplicates drop individid, force
|
||||
save cross\womanresidency, replace
|
||||
|
||||
use membership
|
||||
drop if (mem_edate != . & mem_edate < $refdate)
|
||||
drop if (mem_sdate != . & mem_sdate > $refdate)
|
||||
gen refdate = $refdate
|
||||
rename mem_sobserveid observeid
|
||||
duplicates drop individid, force
|
||||
sort observeid
|
||||
merge observeid using observation
|
||||
tab _merge
|
||||
drop if _merge!=3
|
||||
drop _merge
|
||||
rename locationid sociallocid
|
||||
sort individid
|
||||
merge individid using individual
|
||||
tab _merge
|
||||
drop if _merge != 3
|
||||
drop _merge
|
||||
duplicates drop individid, force
|
||||
keep if gender == "2"
|
||||
sort individ
|
||||
merge individid using cross\womanresidency
|
||||
gen isresident = (sociallocid==locationid)
|
||||
gen communeid = substr(sociallocid, 1,2)
|
||||
drop if isresident == $isresident
|
||||
replace communeid = "00" if $communeid==0
|
||||
drop if communeid ! ="0$communeid"
|
||||
gen age = floor((refdate-birthdate)/365.5)
|
||||
drop if age < 15 | age > 49
|
||||
recode age (min/0=1 "<1") (1/4=2 "1-4") (5/9=3 "5-9")(10/14=4 "10-14") (15/19=5 "15-19") (20/24=6 "20-24") (25/29=7 "25-29") (30/34=8 "30-34") (35/39=9 "35-39") (40/44=10 "40-44") (45/49=11 "45-49")(50/54=12 "50-54") (55/59=13 "55-59") (60/64=14 "60-64") (65/69=15 "65-69") (70/74=16 "70-74") (75/79=17 "75-79") (80/max=18 ">=80") , gen (agegrp)
|
||||
|
||||
sort communeid agegrp
|
||||
collapse (count) women = mem_episodeid , by (agegrp communeid refdate)
|
||||
save cross\WomenBeginYear, replace
|
||||
cd e:\chililabdata
|
50
Chililabdata/GenWomenEndYear.do
Normal file
50
Chililabdata/GenWomenEndYear.do
Normal file
@@ -0,0 +1,50 @@
|
||||
clear all
|
||||
set mem 200M
|
||||
cd e:\chililabdata\data
|
||||
use individual
|
||||
sort individid
|
||||
save individual, replace
|
||||
use observation
|
||||
sort observeid
|
||||
save observation, replace
|
||||
use individres
|
||||
drop if (res_edate != . & res_edate < $refdate)
|
||||
drop if (res_sdate != . & res_sdate > $refdate)
|
||||
sort individ
|
||||
duplicates drop individid, force
|
||||
save cross\womanresidency, replace
|
||||
|
||||
use membership
|
||||
drop if (mem_edate != . & mem_edate < $refdate)
|
||||
drop if (mem_sdate != . & mem_sdate > $refdate)
|
||||
gen refdate = $refdate
|
||||
rename mem_sobserveid observeid
|
||||
duplicates drop individid, force
|
||||
sort observeid
|
||||
merge observeid using observation
|
||||
tab _merge
|
||||
drop if _merge!=3
|
||||
drop _merge
|
||||
rename locationid sociallocid
|
||||
sort individid
|
||||
merge individid using individual
|
||||
tab _merge
|
||||
drop if _merge != 3
|
||||
drop _merge
|
||||
duplicates drop individid, force
|
||||
keep if gender == "2"
|
||||
sort individ
|
||||
merge individid using cross\womanresidency
|
||||
gen isresident = (sociallocid==locationid)
|
||||
gen communeid = substr(sociallocid, 1,2)
|
||||
drop if isresident == $isresident
|
||||
replace communeid = "00" if $communeid==0
|
||||
drop if communeid ! ="0$communeid"
|
||||
gen age = floor((refdate-birthdate)/365.5)
|
||||
drop if age < 15 | age > 49
|
||||
recode age (min/0=1 "<1") (1/4=2 "1-4") (5/9=3 "5-9")(10/14=4 "10-14") (15/19=5 "15-19") (20/24=6 "20-24") (25/29=7 "25-29") (30/34=8 "30-34") (35/39=9 "35-39") (40/44=10 "40-44") (45/49=11 "45-49")(50/54=12 "50-54") (55/59=13 "55-59") (60/64=14 "60-64") (65/69=15 "65-69") (70/74=16 "70-74") (75/79=17 "75-79") (80/max=18 ">=80") , gen (agegrp)
|
||||
|
||||
sort communeid agegrp refdate
|
||||
collapse (count) women = mem_episodeid , by (agegrp communeid refdate)
|
||||
save cross\WomenEndYear, replace
|
||||
cd e:\chililabdata
|
21
Chililabdata/GenWomenInYear.do
Normal file
21
Chililabdata/GenWomenInYear.do
Normal file
@@ -0,0 +1,21 @@
|
||||
clear all
|
||||
set memory 200M
|
||||
global refdate = mdy(1,1,$year)
|
||||
cd e:\chililabdata\
|
||||
do genWomenBeginYear
|
||||
cd e:\chililabdata
|
||||
global refdate = mdy(12,31,$year)
|
||||
do genWomenEndYear
|
||||
|
||||
cd e:\chililabdata\data\cross
|
||||
use WomenBeginYear
|
||||
append using WomenEndYear
|
||||
sort agegrp
|
||||
collapse (mean) women, by (agegrp)
|
||||
replace women = floor(women)
|
||||
sort agegrp
|
||||
save WomenInYear, replace
|
||||
|
||||
cd e:\chililabdata
|
||||
|
||||
|
27
Chililabdata/GenYearMaritalstatus.do
Normal file
27
Chililabdata/GenYearMaritalstatus.do
Normal file
@@ -0,0 +1,27 @@
|
||||
clear all
|
||||
set mem 800M
|
||||
cd data
|
||||
use observation
|
||||
sort observeid
|
||||
save observation, replace
|
||||
use indmarstatus
|
||||
keep individid marstatusid mar_sobserveid
|
||||
rename mar_sobserveid observeid
|
||||
sort observeid
|
||||
merge observeid using observation, nokeep keep (obs_de_date)
|
||||
keep if _merge ==3
|
||||
global refdate = mdy(12,31,2011)
|
||||
drop if $refdate < obs_de_date
|
||||
gen year = year(obs_de_date)
|
||||
gen period = year($refdate )-year(obs_de_date ) +1
|
||||
drop obs_de_date
|
||||
expand period
|
||||
sort individid year
|
||||
by individid year: gen p= _n-1
|
||||
gen rYear = year + p
|
||||
sort individ rYear
|
||||
gen refyear = year($refdate )
|
||||
sort individid year
|
||||
egen maxYear = max(year), by(individid rYear)
|
||||
sort individ rYear
|
||||
keep if year == maxYear
|
28
Chililabdata/Gencrosshouseholdhead.do
Normal file
28
Chililabdata/Gencrosshouseholdhead.do
Normal file
@@ -0,0 +1,28 @@
|
||||
use observation
|
||||
sort observeid
|
||||
save observation, replace
|
||||
use household_head
|
||||
keep individid socialgpid hhd_sdate
|
||||
gen refdate = $refdate
|
||||
drop if refdate < hhd_sdate
|
||||
gen period = qofd(refdate )-qofd(hhd_sdate ) +1
|
||||
expand period
|
||||
sort individid hhd_sdate
|
||||
by individid hhd_sdate: gen p= _n-1
|
||||
gen quarterdate = qofd(hhd_sdate) + p
|
||||
gen refquarter = qofd(refdate )
|
||||
sort individid quarterdate
|
||||
egen maxhhd_sdate = max(hhd_sdate), by(individid quarterdate)
|
||||
keep if hhd_sdate == maxhhd_sdate
|
||||
sort individid
|
||||
tostring quarterdate, generate(key)
|
||||
replace key = socialgpid + individid + key
|
||||
duplicates drop key, force
|
||||
sort key
|
||||
save crossehousehodlheadtemp, replace
|
||||
keep if refquarter == quarterdate
|
||||
format refdate %td
|
||||
sort individid
|
||||
duplicates drop individid, force
|
||||
save cross\crosshouseholdhead, replace
|
||||
|
30
Chililabdata/Genworking.do
Normal file
30
Chililabdata/Genworking.do
Normal file
@@ -0,0 +1,30 @@
|
||||
clear all
|
||||
cd \chililabdata\data
|
||||
global startdate = mdy(1,1,2004)
|
||||
set memory 1200M
|
||||
do ..\GenMaritalstatus
|
||||
do ..\GenCrossEducation
|
||||
do ..\GenCrossResidency
|
||||
do ..\GenCrossHouseResidency
|
||||
do ..\GenCrossMembership
|
||||
do ..\GenCrossOccupation
|
||||
do ..\GenCrossRelatonship
|
||||
do ..\GenCrossMembership
|
||||
do ..\Gencrosshouseholdhead
|
||||
do ..\GenCrossHouseholdinfo
|
||||
do ..\GenCrossReligionInfo
|
||||
do ..\GenCrossMedInsurance.do
|
||||
do ..\MergeMarstatus
|
||||
do ..\MergeResidency
|
||||
do ..\MergeBirthDate
|
||||
do ..\MergeReligion
|
||||
do ..\MergeEducation
|
||||
do ..\MergeOcupation
|
||||
do ..\MergePartnerInfo
|
||||
do ..\MergeHouseholdhead
|
||||
do ..\MergeHouseholdinfo
|
||||
do ..\MergeMedinsurance
|
||||
do ..\createlabels
|
||||
save $outname, replace
|
||||
cd e:\chililabdata
|
||||
window stopbox note "The cross working file was saved as " $outname
|
102
Chililabdata/Getmssqldata.do
Normal file
102
Chililabdata/Getmssqldata.do
Normal file
@@ -0,0 +1,102 @@
|
||||
clear all
|
||||
* Main routine for attachting all tables from Database Server. This routine is based on */
|
||||
/* DSN */
|
||||
/* and compound for each month that the child is resident and alive */
|
||||
set memory 800M
|
||||
global chililab ="dss"
|
||||
global username ="sa"
|
||||
global password ="123456"
|
||||
cd \chililabdata\data
|
||||
/*individual information*/
|
||||
odbc load, dsn($chililab)user($username) password($password) table("individual")clear
|
||||
save individual, replace
|
||||
odbc load, exec("SELECT * FROM membership" ) dsn($chililab)user($username) password($password) clear
|
||||
save membership, replace
|
||||
odbc load, exec("SELECT * FROM individres" ) dsn($chililab)user($username) password($password) clear
|
||||
save individres, replace
|
||||
odbc load, exec("SELECT * FROM relationship" ) dsn($chililab)user($username) password($password) clear
|
||||
save relationship, replace
|
||||
odbc load, exec("SELECT * FROM religion" ) dsn($chililab)user($username) password($password) clear
|
||||
save religion, replace
|
||||
odbc load, exec("SELECT * FROM education" ) dsn($chililab)user($username) password($password) clear
|
||||
save education, replace
|
||||
odbc load, exec("SELECT * FROM occupation" ) dsn($chililab)user($username) password($password) clear
|
||||
save occupation, replace
|
||||
odbc load, exec("SELECT * FROM indmarstatus" ) dsn($chililab)user($username) password($password) clear
|
||||
save indmarstatus, replace
|
||||
odbc load, exec("SELECT * FROM medinsurance" ) dsn($chililab)user($username) password($password) clear
|
||||
save medinsurance, replace
|
||||
|
||||
|
||||
/*household information*/
|
||||
odbc load, exec("SELECT * FROM socialgroup" ) dsn($chililab)user($username) password($password) clear
|
||||
save socialgroup, replace
|
||||
odbc load, exec("SELECT * FROM householdInfo" ) dsn($chililab)user($username) password($password) clear
|
||||
save householdInfo, replace
|
||||
odbc load, exec("SELECT * FROM houseres" ) dsn($chililab)user($username) password($password) clear
|
||||
save houseres, replace
|
||||
|
||||
/*location information*/
|
||||
odbc load, exec("SELECT * FROM location" ) dsn($chililab)user($username) password($password) clear
|
||||
save location, replace
|
||||
odbc load, exec("SELECT * FROM locationinfo" ) dsn($chililab)user($username) password($password) clear
|
||||
save locationinfo, replace
|
||||
|
||||
/*household information*/
|
||||
odbc load, exec("SELECT * FROM householdInfo" ) dsn($chililab)user($username) password($password) clear
|
||||
save householdInfo, replace
|
||||
odbc load, exec("SELECT * FROM socialgroup" ) dsn($chililab)user($username) password($password) clear
|
||||
save socialgroup, replace
|
||||
odbc load, exec("SELECT * FROM household_head" ) dsn($chililab)user($username) password($password) clear
|
||||
save household_head, replace
|
||||
|
||||
/*death*/
|
||||
odbc load, exec("SELECT * FROM death" ) dsn($chililab)user($username) password($password) clear
|
||||
save death, replace
|
||||
|
||||
/*migration both individual and whole household*/
|
||||
|
||||
odbc load, exec("SELECT * FROM outmigration" ) dsn($chililab)user($username) password($password) clear
|
||||
save outmigration, replace
|
||||
odbc load, exec("SELECT * FROM inmigration" ) dsn($chililab)user($username) password($password) clear
|
||||
save inmigration, replace
|
||||
odbc load, exec("SELECT * FROM householdin" ) dsn($chililab)user($username) password($password) clear
|
||||
save householdin, replace
|
||||
odbc load, exec("SELECT * FROM householdout" ) dsn($chililab)user($username) password($password) clear
|
||||
save householdout, replace
|
||||
|
||||
/*pregnance and birth*/
|
||||
|
||||
odbc load, exec("SELECT * FROM pregnance" ) dsn($chililab)user($username) password($password) clear
|
||||
save pregnance, replace
|
||||
odbc load, exec("SELECT * FROM birth" ) dsn($chililab)user($username) password($password) clear
|
||||
save birth, replace
|
||||
odbc load, exec("SELECT * FROM observation" ) dsn($chililab)user($username) password($password) clear
|
||||
save observation, replace
|
||||
|
||||
/*Libraries */
|
||||
odbc load, exec("SELECT * FROM CountryList" ) dsn($chililab)user($username) password($password) clear
|
||||
save countylist, replace
|
||||
/*Health service using information*/
|
||||
/*odbc load, exec("SELECT * FROM healthserviceusing" ) dsn($chililab)user($username) password($password) clear*/
|
||||
/*save healthservice, replace */
|
||||
/*odbc load, exec("SELECT * FROM ah3" ) dsn($chililab)user($username) password($password) clear*/
|
||||
/*save ah3, replace */
|
||||
|
||||
/*disability*/
|
||||
|
||||
odbc load, exec("SELECT * FROM tbldisability" ) dsn($chililab)user($username) password($password) clear
|
||||
save tbldisability, replace
|
||||
/*Smoking*/
|
||||
|
||||
odbc load, exec("SELECT * FROM tblSmoking" ) dsn($chililab)user($username) password($password) clear
|
||||
save tblSmoking, replace
|
||||
odbc load, exec("SELECT * FROM tblSmokingDetails" ) dsn($chililab)user($username) password($password) clear
|
||||
save tblSmokingDetails, replace
|
||||
/*Pregnance*/
|
||||
|
||||
odbc load, exec("SELECT * FROM pregnance" ) dsn($chililab)user($username) password($password) clear
|
||||
save pregnance, replace
|
||||
window stopbox note "All data was saved in d:\chililabdata\Data folder"
|
||||
cd \chililabdata
|
||||
clear all
|
13
Chililabdata/MergeBirthDate.do
Normal file
13
Chililabdata/MergeBirthDate.do
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
use cross\crossdata
|
||||
sort fatherid
|
||||
merge fatherid using cross\crossfbod
|
||||
drop if _merge ==2
|
||||
drop _merge
|
||||
|
||||
sort motherid
|
||||
merge motherid using cross\crossmbod
|
||||
drop if _merge ==2
|
||||
drop _merge
|
||||
|
||||
save cross\crossdata, replace
|
26
Chililabdata/MergeEducation.do
Normal file
26
Chililabdata/MergeEducation.do
Normal file
@@ -0,0 +1,26 @@
|
||||
use cross\crossdata, clear
|
||||
sort individid
|
||||
merge individid using cross\crosseducation
|
||||
drop if _merge ==2
|
||||
drop _merge
|
||||
save cross\crossdata, replace
|
||||
|
||||
use cross\crosseducation, clear
|
||||
sort fatherid
|
||||
save, replace
|
||||
use cross\crossdata
|
||||
sort fatherid
|
||||
merge fatherid using cross\crosseducation
|
||||
drop if _merge ==2
|
||||
drop _merge
|
||||
save cross\crossdata, replace
|
||||
use cross\crosseducation,clear
|
||||
sort motherid
|
||||
save, replace
|
||||
use cross\crossdata
|
||||
sort motherid
|
||||
merge motherid using cross\crosseducation
|
||||
drop if _merge ==2
|
||||
drop _merge
|
||||
|
||||
save cross\crossdata, replace
|
7
Chililabdata/MergeHouseholdHead.do
Normal file
7
Chililabdata/MergeHouseholdHead.do
Normal file
@@ -0,0 +1,7 @@
|
||||
use cross\crossdata, clear
|
||||
sort individid
|
||||
merge individid using cross\crosshouseholdhead
|
||||
drop if _merge ==2
|
||||
rename _merge ishouseholdhead
|
||||
replace ishouseholdhead =0 if ishouseholdhead==3
|
||||
save cross\crossdata, replace
|
6
Chililabdata/MergeHouseholdinfo.do
Normal file
6
Chililabdata/MergeHouseholdinfo.do
Normal file
@@ -0,0 +1,6 @@
|
||||
use cross\crossdata, clear
|
||||
sort socialgpid individid
|
||||
merge socialgpid using cross\crosshouseholdinfo
|
||||
drop if _merge ==2
|
||||
egen totalnumbers = count (bod), by (socialgpid)
|
||||
save cross\crossdata, replace
|
11
Chililabdata/MergeMarstatus.do
Normal file
11
Chililabdata/MergeMarstatus.do
Normal file
@@ -0,0 +1,11 @@
|
||||
use cross\crossmarstatus
|
||||
sort individid
|
||||
save cross\crossmarstatus, replace
|
||||
|
||||
use cross\crossmembership
|
||||
sort individid
|
||||
merge individid using cross\crossmarstatus
|
||||
drop if _merge ==2
|
||||
drop _merge
|
||||
save cross\crossdata, replace
|
||||
close
|
8
Chililabdata/MergeMedinsurance.do
Normal file
8
Chililabdata/MergeMedinsurance.do
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
use cross\crossdata, clear
|
||||
drop _merge
|
||||
sort individid
|
||||
merge individid using cross\crossmedinsurance, nokeep keep (hinsid)
|
||||
drop if _merge ==2
|
||||
save cross\crossdata, replace
|
||||
|
21
Chililabdata/MergeOcupation.do
Normal file
21
Chililabdata/MergeOcupation.do
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
use cross\crossdata, clear
|
||||
sort individid
|
||||
merge individid using cross\crossoccupation
|
||||
drop if _merge ==2
|
||||
drop _merge
|
||||
save cross\crossdata, replace
|
||||
use cross\crossdata, clear
|
||||
sort motherid
|
||||
merge motherid using cross\crossmoccupation
|
||||
drop if _merge ==2
|
||||
sort individid
|
||||
drop _merge
|
||||
save cross\crossdata, replace
|
||||
use cross\crossdata, clear
|
||||
sort fatherid
|
||||
merge fatherid using cross\crossfoccupation
|
||||
drop if _merge ==2
|
||||
drop _merge
|
||||
save cross\crossdata, replace
|
||||
|
7
Chililabdata/MergePartnerInfo.do
Normal file
7
Chililabdata/MergePartnerInfo.do
Normal file
@@ -0,0 +1,7 @@
|
||||
use cross\crossdata, clear
|
||||
sort individid
|
||||
merge individid using cross\crossrelationship
|
||||
drop if _merge ==2
|
||||
drop _merge
|
||||
sort socialgpid
|
||||
save cross\crossdata, replace
|
6
Chililabdata/MergeReligion.do
Normal file
6
Chililabdata/MergeReligion.do
Normal file
@@ -0,0 +1,6 @@
|
||||
use cross\crossdata, clear
|
||||
sort individid
|
||||
merge individid using cross\crossReligionInfo, nokeep keep(religionid)
|
||||
drop if _merge ==2
|
||||
drop _merge
|
||||
save cross\crossdata, replace
|
9
Chililabdata/MergeResidency.do
Normal file
9
Chililabdata/MergeResidency.do
Normal file
@@ -0,0 +1,9 @@
|
||||
use cross\crossdata, clear
|
||||
sort individid
|
||||
merge individid using cross\crossresidency
|
||||
tab _merge
|
||||
drop if _merge ==2
|
||||
drop _merge
|
||||
gen isresident =0
|
||||
replace isresident =(sociallocid==locationid)
|
||||
save cross\crossdata, replace
|
52
Chililabdata/Reg_Normalizing.do
Normal file
52
Chililabdata/Reg_Normalizing.do
Normal file
@@ -0,0 +1,52 @@
|
||||
clear
|
||||
cd c:\chililabdata\data
|
||||
use individres.dta
|
||||
gen eventdate=res_sdate/86400000
|
||||
keep individid res_seventtype eventdate
|
||||
rename res_seventtype eventtype
|
||||
gen year = year(eventdate)
|
||||
replace year = 2004 if year <2004
|
||||
save statevent, replace
|
||||
|
||||
use individres.dta
|
||||
gen eventdate=res_edate/86400000 if res_edate!=.
|
||||
keep individid res_eeventtype eventdate
|
||||
rename res_eeventtype eventtype
|
||||
gen year = year(eventdate)
|
||||
replace year = 2013 if year > 2013
|
||||
replace year = 2013 if eventdate==.
|
||||
replace year = 2004 if year <2004
|
||||
replace eventtype = "CONT" if eventdate==.
|
||||
replace eventdate = mdy(12,31,2013) if eventdate==.
|
||||
append using statevent
|
||||
duplicates drop individ eventtype year, force
|
||||
sort individid year
|
||||
|
||||
gen period = year[_n+1]-year if individ == individid[_n+1]
|
||||
|
||||
expand period if eventtype =="ENU" | eventtype =="IMG" | eventtype =="BTH"
|
||||
sort individid year
|
||||
by individid year: gen p=_n-1
|
||||
replace year = year + p
|
||||
keep if eventtype =="BTH" | eventtype =="ENU" | eventtype =="IMG" | eventtype =="ENT" | eventtype =="CONT"
|
||||
merge m:1 individ using individual, keepusing(birthdate gender)
|
||||
keep if _merge ==3
|
||||
drop _merge
|
||||
destring gender, replace
|
||||
rename gender sex
|
||||
replace birthdate=birthdate/86400000
|
||||
|
||||
format %td eventdate
|
||||
format %td birthdate
|
||||
|
||||
gen birthyear = year(birthdate)
|
||||
|
||||
gen age = year - birthyear
|
||||
drop if age < 0
|
||||
drop if year < 2004
|
||||
drop if year > 2013
|
||||
drop if age > 100
|
||||
d
|
||||
save c:\chililabdata\data\death\longindivid, replace
|
||||
drop if age < 60
|
||||
save c:\chililabdata\data\death\60longindivid, replace
|
26
Chililabdata/code/GenLongBirth.do
Normal file
26
Chililabdata/code/GenLongBirth.do
Normal file
@@ -0,0 +1,26 @@
|
||||
clear
|
||||
|
||||
cd e:\chililabdata\data
|
||||
use individual
|
||||
sort individid
|
||||
save, replace
|
||||
use birth
|
||||
sort individid
|
||||
duplicates drop individid, force
|
||||
merge 1:1 individid using individual, keepusing(gender motherid)
|
||||
rename gender sex
|
||||
rename individid childid
|
||||
rename motherid individid
|
||||
gen socialgpid = substr(observeid,1,9)
|
||||
replace bth_date= bth_date/86400000
|
||||
format bth_date %td
|
||||
gen year = year( bth_date)
|
||||
gen h = halfyear(bth_date)
|
||||
gen round = yh(year,h)-89
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) ==1
|
||||
gen socialkey = socialgpid+ rounds
|
||||
gen individkey = individid+ rounds
|
||||
drop eventid observeid individidGuid _merge h
|
||||
drop if round < 0
|
||||
save rBirths, replace
|
17
Chililabdata/code/GenLongDeath.do
Normal file
17
Chililabdata/code/GenLongDeath.do
Normal file
@@ -0,0 +1,17 @@
|
||||
clear
|
||||
cd e:\chililabdata\data
|
||||
use death
|
||||
gen socialgpid = substr(observeid,1,9)
|
||||
replace dth_date=dth_date/86400000
|
||||
format dth_date %td
|
||||
gen year = year( dth_date)
|
||||
gen h = halfyear(dth_date)
|
||||
gen round = yh(year,h)-89
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) ==1
|
||||
gen socialkey = socialgpid+ rounds
|
||||
gen individkey = individid+ rounds
|
||||
drop EID h eventid observeid year individidGuid
|
||||
duplicates drop individkey, force
|
||||
drop if round < 0
|
||||
save rDeaths, replace
|
16
Chililabdata/code/GenLongInmigration.do
Normal file
16
Chililabdata/code/GenLongInmigration.do
Normal file
@@ -0,0 +1,16 @@
|
||||
clear
|
||||
cd e:\chililabdata\data
|
||||
use inmigration
|
||||
replace img_date=img_date/86400000
|
||||
format img_date %td
|
||||
gen year = year( img_date)
|
||||
gen h = halfyear(img_date)
|
||||
gen round = yh(year,h)-89
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) ==1
|
||||
gen socialkey = socialgpid+ rounds
|
||||
gen individkey = individid+ rounds
|
||||
drop EID h socialgpidGuid rounds eventid observeid year
|
||||
duplicates drop individkey, force
|
||||
drop if round < 0
|
||||
save rImmigration, replace
|
25
Chililabdata/code/GenLongMembership.do
Normal file
25
Chililabdata/code/GenLongMembership.do
Normal file
@@ -0,0 +1,25 @@
|
||||
clear
|
||||
cd e:\chililabdata\data
|
||||
use membership
|
||||
sort individid
|
||||
drop if individid==""
|
||||
replace mem_sdate=mem_sdate/86400000
|
||||
rename mem_sdate sdate
|
||||
format sdate %td
|
||||
gen year = year( sdate)
|
||||
gen h = halfyear(sdate)
|
||||
gen round = yh(year,h)-89
|
||||
sort individid round
|
||||
duplicates drop individid round, force
|
||||
gen period = round[_n+1]-round
|
||||
replace period = 109-89 -round if individ != individid[_n+1]
|
||||
drop mem_episodeid mem_sobserveid mem_seventtype mem_eobserveid mem_edate mem_eeventtype mem_no socialgpidGuid mem_sobserveidGuid mem_eobserveidGuid h year
|
||||
expand period
|
||||
sort individid round
|
||||
by individid round: gen p=_n-1
|
||||
replace round = round+p
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) == 1
|
||||
gen socialkeys = socialgpid + rounds
|
||||
drop period p
|
||||
save rMembership, replace
|
32
Chililabdata/code/GenLongOccupation.do
Normal file
32
Chililabdata/code/GenLongOccupation.do
Normal file
@@ -0,0 +1,32 @@
|
||||
clear all
|
||||
cd data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use occupation
|
||||
rename occ_sobserveid observeid
|
||||
sort observeid
|
||||
merge m:1 observeid using observation, keepusing(obs_entry_date)
|
||||
keep if _merge ==3
|
||||
gen year = year( obs_entry_date/86400000)
|
||||
gen h = halfyear(obs_entry_date/86400000)
|
||||
gen round = yh(year,h)
|
||||
sort individid round
|
||||
gen period = round[_n+1]-round
|
||||
replace period = 109-round if individid!=individid[_n+1]
|
||||
expand period
|
||||
replace round = round-89
|
||||
sort individid round
|
||||
by individid round: gen p= _n-1
|
||||
replace round = round + p
|
||||
drop h period p _merge obs_entry_date
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) == 1
|
||||
gen individkey = individid + rounds
|
||||
sort individkey
|
||||
duplicates drop individkey, force
|
||||
drop occ_episodeid observeid occ_eobserveid
|
||||
save rOccupation, replace
|
||||
|
||||
|
||||
|
16
Chililabdata/code/GenLongOutmigration.do
Normal file
16
Chililabdata/code/GenLongOutmigration.do
Normal file
@@ -0,0 +1,16 @@
|
||||
clear
|
||||
cd e:\chililabdata\data
|
||||
use outmigration
|
||||
replace out_date=out_date/86400000
|
||||
format out_date %td
|
||||
gen year = year( out_date)
|
||||
gen h = halfyear(out_date)
|
||||
gen round = yh(year,h)-89
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) ==1
|
||||
gen socialkey = socialgpid+ rounds
|
||||
gen individkey = individid+ rounds
|
||||
drop EID h socialgpidGuid eventid observeid year
|
||||
duplicates drop individkey, force
|
||||
drop if round < 0
|
||||
save rOutmigration, replace
|
31
Chililabdata/code/GenLongPregnance.do
Normal file
31
Chililabdata/code/GenLongPregnance.do
Normal file
@@ -0,0 +1,31 @@
|
||||
clear
|
||||
cd e:\chililabdata\data
|
||||
use individual
|
||||
sort individid
|
||||
save, replace
|
||||
use pregnance
|
||||
sort individid
|
||||
merge m:1 individid using individual, keepusing(birthdate)
|
||||
drop if _merge!=3
|
||||
drop _merge
|
||||
gen socialgpid = substr(sobserveid,1,9)
|
||||
replace preg_sdate= preg_sdate/86400000
|
||||
rename preg_sdate sdate
|
||||
replace preg_edate= preg_edate/86400000
|
||||
rename preg_edate edate
|
||||
replace birthdate= birthdate/86400000
|
||||
rename birthdate bod
|
||||
format bod %td
|
||||
format sdate %td
|
||||
format edate %td
|
||||
gen year = year( sdate)
|
||||
gen h = halfyear(sdate)
|
||||
gen round = yh(year,h)-89
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) ==1
|
||||
gen socialkey = socialgpid+ rounds
|
||||
gen individkey = individid+ rounds
|
||||
drop eventid sobserveid fatherid fatheridGuid EID rounds h year
|
||||
sort individid round
|
||||
drop if round < 0
|
||||
save rPregnance, replace
|
34
Chililabdata/code/genLongEducation.do
Normal file
34
Chililabdata/code/genLongEducation.do
Normal file
@@ -0,0 +1,34 @@
|
||||
clear all
|
||||
cd data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use education
|
||||
rename edu_sobserveid observeid
|
||||
sort observeid
|
||||
merge m:1 observeid using observation, keepusing(obs_entry_date)
|
||||
keep if _merge ==3
|
||||
gen year = year( obs_entry_date/86400000)
|
||||
gen h = halfyear(obs_entry_date/86400000)
|
||||
gen round = yh(year,h)
|
||||
gen r = round
|
||||
sort individid round
|
||||
gen period = round[_n+1]-round
|
||||
replace period = 109-round if individid!=individid[_n+1]
|
||||
expand period
|
||||
replace round = round-89
|
||||
gen m = round
|
||||
sort individid round
|
||||
by individid round: gen p= _n-1
|
||||
replace round = round + p
|
||||
drop _merge
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) == 1
|
||||
gen individkey = individid + rounds
|
||||
sort individkey
|
||||
duplicates drop individkey, force
|
||||
drop edu_episodeid observeid edu_eobserveid
|
||||
save rEducation, replace
|
||||
|
||||
|
||||
|
33
Chililabdata/code/genLongHouseholdInfo.do
Normal file
33
Chililabdata/code/genLongHouseholdInfo.do
Normal file
@@ -0,0 +1,33 @@
|
||||
clear all
|
||||
cd data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use householdinfo
|
||||
sort observeid
|
||||
merge m:1 observeid using observation, keepusing(obs_entry_date)
|
||||
drop round
|
||||
keep if _merge ==3
|
||||
drop if socialgpid ==""
|
||||
gen year = year( obs_entry_date/86400000)
|
||||
gen h = halfyear(obs_entry_date/86400000)
|
||||
gen round = yh(year,h)
|
||||
sort socialgpid round
|
||||
gen period = round[_n+1]-round
|
||||
replace period = 109-round if socialgpid!=socialgpid[_n+1]
|
||||
expand period
|
||||
replace round = round-89
|
||||
sort socialgpid round
|
||||
by socialgpid round: gen p= _n-1
|
||||
replace round = round + p
|
||||
drop h period p _merge obs_entry_date
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) == 1
|
||||
gen socialkey = socialgpid+ rounds
|
||||
drop hhinforid
|
||||
sort socialkey
|
||||
duplicates drop socialkey, force
|
||||
save rHouseholdInfo, replace
|
||||
|
||||
|
||||
|
38
Chililabdata/code/genLongMarStatus.do
Normal file
38
Chililabdata/code/genLongMarStatus.do
Normal file
@@ -0,0 +1,38 @@
|
||||
clear all
|
||||
cd e:\chililabdata\data
|
||||
use individual
|
||||
sort individid
|
||||
save, replace
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use indmarstatus
|
||||
rename mar_sobserveid observeid
|
||||
sort observeid
|
||||
merge m:1 observeid using observation, keepusing(obs_entry_date)
|
||||
keep if _merge ==3
|
||||
gen year = year( obs_entry_date/86400000)
|
||||
gen h = halfyear(obs_entry_date/86400000)
|
||||
gen round = yh(year,h)
|
||||
sort individid round
|
||||
gen period = round[_n+1]-round
|
||||
replace period = 109-round if individid!=individid[_n+1]
|
||||
expand period
|
||||
replace round = round-89
|
||||
sort individid round
|
||||
by individid round: gen p= _n-1
|
||||
replace round = round + p
|
||||
drop period p _merge
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) == 1
|
||||
gen individkey = individid + rounds
|
||||
sort individkey
|
||||
duplicates drop individkey, force
|
||||
|
||||
sort individid
|
||||
merge m:1 individid using individual, keepusing(gender ethnicid)
|
||||
drop mar_episodeid observeid mar_eobserveid obs_entry_date year h _merge
|
||||
save rMarstatus, replace
|
||||
|
||||
|
||||
|
26
Chililabdata/code/newcode/GenLongBirth.do
Normal file
26
Chililabdata/code/newcode/GenLongBirth.do
Normal file
@@ -0,0 +1,26 @@
|
||||
clear
|
||||
|
||||
cd e:\chililabdata\data
|
||||
use individual
|
||||
sort individid
|
||||
save, replace
|
||||
use birth
|
||||
sort individid
|
||||
duplicates drop individid, force
|
||||
merge 1:1 individid using individual, keepusing(gender motherid)
|
||||
rename gender sex
|
||||
rename individid childid
|
||||
rename motherid individid
|
||||
gen socialgpid = substr(observeid,1,9)
|
||||
replace bth_date= bth_date/86400000
|
||||
format bth_date %td
|
||||
gen year = year( bth_date)
|
||||
gen h = halfyear(bth_date)
|
||||
gen round = yh(year,h)-89
|
||||
tostring round, generate(rounds)
|
||||
replace rounds = "0" + rounds if strlen(rounds) ==1
|
||||
gen socialkey = socialgpid+ rounds
|
||||
gen individkey = individid+ rounds
|
||||
drop eventid observeid individidGuid _merge h
|
||||
drop if round < 0
|
||||
save rBirths, replace
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user