Uloading
Uloading
This commit is contained in:
97
Chililabdata/newcode/currentlist.do
Normal file
97
Chililabdata/newcode/currentlist.do
Normal file
@@ -0,0 +1,97 @@
|
||||
clear all
|
||||
cd ..\data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use membership.dta
|
||||
sort individid mem_sdate
|
||||
replace mem_sdate = mem_sdate/86400000
|
||||
egen maxdate = max( mem_sdate), by (individid)
|
||||
keep if mem_sdate==maxdate
|
||||
keep if mem_edate==.
|
||||
gen observeid = mem_sobserveid
|
||||
gen round = substr( mem_sobserveid, 10,3)
|
||||
duplicates drop individid round, force
|
||||
gen individkey = individid + round
|
||||
gen householdkey = socialgpid + round
|
||||
duplicates drop individid, force
|
||||
merge m:1 observeid using observation, keepusing(locationid)
|
||||
keep if _merge ==3
|
||||
drop _merge observeid mem_episodeid mem_sobserveid mem_seventtype mem_eobserveid mem_eeventtype mem_no round mem_sdate mem_edate maxdate socialgpidGuid mem_sobserveidGuid mem_eobserveidGuid
|
||||
/* get individual core information */
|
||||
sort individid
|
||||
merge m:1 individid using ..\newcode\data\std_individual
|
||||
keep if _merge ==3
|
||||
drop _merge
|
||||
|
||||
/* get education information */
|
||||
sort individkey
|
||||
merge 1:1 individkey using ..\newcode\data\std_education.dta
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
|
||||
/* get occupation information */
|
||||
sort individkey
|
||||
merge 1:1 individkey using ..\newcode\data\std_occupation.dta
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
|
||||
/* get marial status information */
|
||||
sort individkey
|
||||
merge 1:1 individkey using ..\newcode\data\std_marstatus.dta
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
|
||||
/* get religion information */
|
||||
sort individkey
|
||||
merge 1:1 individkey using ..\newcode\data\std_religion.dta
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
|
||||
/* get marriage information */
|
||||
sort individkey
|
||||
merge 1:1 individkey using ..\newcode\data\std_relationship.dta, keepusing(partnerid marriagedate marriagetype)
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
replace marstatusid = 1 if marriagetype =="MAR"
|
||||
|
||||
/* get Insurance information */
|
||||
sort individkey
|
||||
merge 1:1 individkey using ..\newcode\data\std_medinsurance.dta, keepusing(hinsid)
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
|
||||
/* get househead information */
|
||||
sort individkey
|
||||
merge 1:1 individkey using ..\newcode\data\std_househeadlist
|
||||
keep if _merge!=2
|
||||
gen ishousehead =0
|
||||
replace ishousehead =0 if _merge ==1
|
||||
replace ishousehead =1 if _merge==3
|
||||
drop _merge
|
||||
merge 1:1 individkey using ..\newcode\data\std_recidency.dta
|
||||
keep if _merge!=2
|
||||
gen isresident =0
|
||||
replace isresident=1 if _merge==3
|
||||
drop _merge
|
||||
sort individid
|
||||
merge m:1 individid using ..\newcode\data\std_enterexit
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
label drop _merge
|
||||
gen CommuneId = substr(locationid, 1,2)
|
||||
|
||||
/* recode */
|
||||
label variable sex "Gioi tinh"
|
||||
label variable socialgpid "Ma ho"
|
||||
label variable fatherid "Ma so bo"
|
||||
label variable motherid "Ma so me"
|
||||
label variable hinsid "Bao hiem y te"
|
||||
label variable ishousehead "La chu ho"
|
||||
label define chuho 1 "La chu ho" 0 "Khong la chu ho"
|
||||
label values ishousehead chuho
|
||||
label variable marriagetype "Hinh thuc hon nhan"
|
||||
label variable CommuneId "Ma xa"
|
||||
|
||||
|
||||
save ..\newcode\data\currentlist,replace
|
77
Chililabdata/newcode/genstd_allbirths.do
Normal file
77
Chililabdata/newcode/genstd_allbirths.do
Normal file
@@ -0,0 +1,77 @@
|
||||
clear all
|
||||
cd c:\chililabdata\newcode\data
|
||||
use std_births
|
||||
gen year = year(bod)
|
||||
tostring year, replace
|
||||
sort individid
|
||||
drop individkey
|
||||
rename individid childid
|
||||
rename bornid childbornid
|
||||
|
||||
|
||||
|
||||
gen individkey = motherid + round
|
||||
sort individkey
|
||||
merge m:1 individkey using std_education, keepusing(eduid)
|
||||
keep if _merge !=2
|
||||
rename eduid meduid
|
||||
drop _merge
|
||||
|
||||
merge m:1 individkey using std_occupation, keepusing(occupationid)
|
||||
keep if _merge !=2
|
||||
rename occupationid moccupationid
|
||||
drop _merge
|
||||
|
||||
replace individkey = fatherid + round
|
||||
sort individkey
|
||||
merge m:1 individkey using std_education, keepusing(eduid)
|
||||
keep if _merge !=2
|
||||
rename eduid feduid
|
||||
drop _merge
|
||||
|
||||
merge m:1 individkey using std_occupation,keepusing(occupationid)
|
||||
keep if _merge !=2
|
||||
rename occupationid foccupationid
|
||||
drop _merge
|
||||
drop individkey
|
||||
rename motherid individid
|
||||
sort individid
|
||||
merge m:1 individid using std_individual , keepusing(birthdate bornid)
|
||||
keep if _merge !=2
|
||||
drop _merge
|
||||
rename birthdate mbod
|
||||
rename bornid mbornid
|
||||
rename individid motherid
|
||||
|
||||
rename fatherid individid
|
||||
sort individid
|
||||
merge m:1 individid using std_individual , keepusing(birthdate bornid)
|
||||
keep if _merge !=2
|
||||
drop _merge
|
||||
rename birthdate fbod
|
||||
rename bornid fbornid
|
||||
rename individid fatherid
|
||||
rename childid individid
|
||||
drop motheridGuid fatheridGuid appround
|
||||
replace householdkey = socialgpid + year
|
||||
merge m:1 householdkey using houseinfo, keepusing (quintile)
|
||||
keep if _merge !=2
|
||||
drop _merge
|
||||
sort individid
|
||||
save std_allbirths, replace
|
||||
|
||||
use std_individual
|
||||
keep if length(motherid)==11
|
||||
sort motherid birthdate
|
||||
|
||||
gen prevchildid = individid[_n-1] if mother[_n-1] ==motherid
|
||||
gen prevgender = sex[_n-1] if mother[_n-1] ==motherid
|
||||
gen prevbirthdate = birthdate[_n-1] if mother[_n-1] ==motherid
|
||||
sort individid
|
||||
save tmp_individual, replace
|
||||
use std_allbirths
|
||||
merge 1:1 individid using tmp_individual, keepusing(prevchildid prevgender prevbirthdate)
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
|
||||
cd c:\chililabdata\newcode
|
33
Chililabdata/newcode/genstd_birth.do
Normal file
33
Chililabdata/newcode/genstd_birth.do
Normal file
@@ -0,0 +1,33 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use individual
|
||||
sort individid
|
||||
save individual, replace
|
||||
use birth
|
||||
gen socialgpid = substr(observeid,1,9)
|
||||
gen round = substr(observeid, 10,3)
|
||||
replace bth_date=bth_date/86400000
|
||||
format bth_date %td
|
||||
merge m:1 observeid using observation, keepusing(locationid)
|
||||
keep if _merge ==3
|
||||
drop observeid _merge
|
||||
sort individid
|
||||
merge m:1 individid using individual
|
||||
drop if _merge !=3
|
||||
drop _merge
|
||||
drop eventid individidGuid ind_name individidGuid eventid birthdate
|
||||
rename bth_date bod
|
||||
gen individkey = individid+ round
|
||||
gen householdkey = socialgpid + round
|
||||
sort individkey
|
||||
label variable gender "Gioi tinh"
|
||||
gen communeid = substr(locationid,3,2)
|
||||
destring gender, replace
|
||||
label define sex 1 "Nam" 2 "Nu"
|
||||
label values gender sex
|
||||
destring ethnicid, replace
|
||||
duplicates drop individid, force
|
||||
save ..\newcode\data\std_births, replace
|
51
Chililabdata/newcode/genstd_death.do
Normal file
51
Chililabdata/newcode/genstd_death.do
Normal file
@@ -0,0 +1,51 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use individual
|
||||
sort individid
|
||||
save individual, replace
|
||||
|
||||
use death
|
||||
gen socialgpid = substr(observeid,1,9)
|
||||
replace dth_date=dth_date/86400000
|
||||
format dth_date %td
|
||||
sort observeid
|
||||
merge m:1 observeid using observation, keepusing(locationid obs_round)
|
||||
keep if _merge ==3
|
||||
drop observeid _merge
|
||||
rename obs_round round
|
||||
tostring round, replace
|
||||
replace round = "00" + round if strlen(round) == 1
|
||||
replace round ="0" + round if strlen(round)==2
|
||||
merge m:1 individid using individual
|
||||
drop if _merge !=3
|
||||
drop _merge
|
||||
replace birthdate=birthdate/86400000
|
||||
format dth_date %td
|
||||
|
||||
gen age = floor((dth_date-birthdate)/365.5)
|
||||
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/84=18 ">=80") (85/max=19 ">=85") , gen (agegrp)
|
||||
gen individkey = individid+ round
|
||||
gen householdkey = socialgpid + round
|
||||
sort individkey
|
||||
drop fatheridGuid motheridGuid bornid appround eventid individidGuid EID fatherid motherid ind_name dth_otherplace dth_reason birthdate
|
||||
|
||||
gen communeid = substr(locationid, 1,2)
|
||||
|
||||
/*Recode - labeling */
|
||||
label variable communeid "Ma xa"
|
||||
label define noimat 1 "Tai nha" 2 "Co so y te" 3 "Khac"
|
||||
label define nguyennhan 1 "Benh tat" 2 "Gia yeu" 3 "Tai nan" 4 "Ly do khac"
|
||||
label values dth_placeid noimat
|
||||
label values dth_reasonid nguyennhan
|
||||
destring ethnicid, replace
|
||||
label define ethnic 1 "1. Kinh" 2 "2. San diu" 3 "3. Tay" 4 "4. Hoa" 5 "5. Khac" 6 "6. Thai" 7 "7. Kho me" 8 "8. Man" 9 "4. Tho"
|
||||
label values ethnic ethnic
|
||||
rename gender sex
|
||||
destring sex, replace
|
||||
label define sexs 1 "1. Nam" 2 "2. Nu"
|
||||
label values sex sexs
|
||||
|
||||
save ..\newcode\data\std_deaths, replace
|
38
Chililabdata/newcode/genstd_education.do
Normal file
38
Chililabdata/newcode/genstd_education.do
Normal file
@@ -0,0 +1,38 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use education
|
||||
rename edu_sobserveid observeid
|
||||
sort individid observeid
|
||||
duplicates drop individid observeid, force
|
||||
merge m:1 observeid using observation, keepusing(obs_round obs_entry_date)
|
||||
keep if _merge==3
|
||||
drop _merge
|
||||
rename obs_round round
|
||||
duplicates drop individid round, force
|
||||
rename obs_entry_date visit_date
|
||||
sort individid round
|
||||
gen rounds =0
|
||||
replace rounds = round[_n+1] if individid[_n]==individid[_n+1]
|
||||
replace rounds =23 if rounds ==0
|
||||
gen period = rounds -round
|
||||
expand period
|
||||
sort individid round
|
||||
egen minround = min(round), by (individid)
|
||||
by individid: gen step=_n-1
|
||||
replace round = minround + step
|
||||
tostring round, replace
|
||||
replace round = "00" + round if strlen(round) == 1
|
||||
replace round ="0" + round if strlen(round)==2
|
||||
gen individkey = individ + round
|
||||
drop edu_episodeid edu_eobserveid observeid rounds period minround step
|
||||
sort individkey
|
||||
destring edu, replace
|
||||
recode eduid (1/3 = 1) (8/11 = 1) (12/14 = 2) (15/19 = 3) (4/7=4)
|
||||
label define edu 1 "1. Duoi THCS" 2 "2. THSC" 3 "3. THPT" 4 "4. Tren THPT"
|
||||
label values eduid edu
|
||||
save ..\newcode\data\std_education, replace
|
||||
|
||||
|
27
Chililabdata/newcode/genstd_events.do
Normal file
27
Chililabdata/newcode/genstd_events.do
Normal file
@@ -0,0 +1,27 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use individres.dta
|
||||
gen sround = substr( res_sobserveid, 10,3)
|
||||
destring sround, replace
|
||||
drop res_sobserveidGuid res_eobserveidGuid
|
||||
gen eround ="023" if res_eobserveid==""
|
||||
replace eround = substr( res_eobserveid, 10,3) if res_eobserveid !=""
|
||||
destring(eround), replace
|
||||
duplicates drop individid res_sobserveid,force
|
||||
duplicates drop individid eround,force
|
||||
gen period = eround - sround
|
||||
expand period
|
||||
sort individid locationid sround
|
||||
by individid locationid sround: gen step=_n-1
|
||||
gen round = sround + step
|
||||
duplicates drop individid round, force
|
||||
drop if round > 22
|
||||
tostring round, replace
|
||||
replace round = "00" + round if strlen(round) == 1
|
||||
replace round ="0" + round if strlen(round)==2
|
||||
gen individkey = individid + round
|
||||
sort individkey
|
||||
drop res_episodeid res_seventtype res_sdate res_sobserveid res_eeventtype res_eobserveid res_edate sround eround period step
|
||||
save ..\newcode\data\std_recidency, replace
|
||||
|
||||
|
38
Chililabdata/newcode/genstd_househead.do
Normal file
38
Chililabdata/newcode/genstd_househead.do
Normal file
@@ -0,0 +1,38 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use household_head
|
||||
rename hhd_sobserveid observeid
|
||||
sort observeid
|
||||
duplicates drop observeid, force
|
||||
merge m:1 observeid using observation, keepusing(obs_round obs_entry_date)
|
||||
keep if _merge==3
|
||||
drop _merge
|
||||
rename obs_round sround
|
||||
rename obs_entry_date visit_date
|
||||
replace visit_date = visit_date/86400000
|
||||
sort socialgpid sround
|
||||
gen eround =0
|
||||
replace eround = sround[_n+1] if socialgpid[_n]==socialgpid[_n+1]
|
||||
replace eround =23 if eround ==0
|
||||
gen period = eround -sround
|
||||
expand period
|
||||
sort socialgpid sround
|
||||
egen minround = min(sround), by (socialgpid)
|
||||
by socialgpid: gen step=_n-1
|
||||
gen round = minround + step
|
||||
drop if round > 22
|
||||
tostring round, replace
|
||||
replace round = "00" + round if strlen(round) == 1
|
||||
replace round ="0" + round if strlen(round)==2
|
||||
gen householdkey = socialgpid + round
|
||||
drop hhd_episodeid observeid hhd_sdate hhd_seventtype hhd_eobserveid hhd_edate hhd_eeventtype sround eround period minround step
|
||||
rename individid househeadid
|
||||
sort householdkey
|
||||
gen individkey = househeadid + round
|
||||
/*recode*/
|
||||
|
||||
save ..\newcode\data\std_househead, replace
|
||||
|
67
Chililabdata/newcode/genstd_householdinfo.do
Normal file
67
Chililabdata/newcode/genstd_householdinfo.do
Normal file
@@ -0,0 +1,67 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use householdinfo
|
||||
sort observeid
|
||||
duplicates drop observeid, force
|
||||
merge m:1 observeid using observation, keepusing(obs_round obs_entry_date)
|
||||
keep if _merge==3
|
||||
drop _merge
|
||||
drop round
|
||||
rename obs_round sround
|
||||
rename obs_entry_date visit_date
|
||||
replace visit_date = visit_date/86400000
|
||||
sort socialgpid sround
|
||||
gen eround =0
|
||||
replace eround = sround[_n+1] if socialgpid[_n]==socialgpid[_n+1]
|
||||
replace eround =23 if eround ==0
|
||||
gen period = eround -sround
|
||||
expand period
|
||||
sort socialgpid sround
|
||||
egen minround = min(sround), by (socialgpid)
|
||||
by socialgpid: gen step=_n-1
|
||||
gen round = minround + step
|
||||
drop if round > 22
|
||||
tostring round, replace
|
||||
replace round = "00" + round if strlen(round) == 1
|
||||
replace round ="0" + round if strlen(round)==2
|
||||
gen householdkey = socialgpid + round
|
||||
drop hhinforid observeid sround eround period minround step eco_inside_sup eco_inside_suptd eco_outside_sup eco_outside_suptd
|
||||
merge 1:1 householdkey using ..\newcode\data\std_househead, keepusing(househeadid)
|
||||
drop if _merge ==2
|
||||
drop responsorID entryDate fieldWrkr dataClerk deDate statusDat _merge
|
||||
sort householdkey
|
||||
/*recode*/
|
||||
label variable roof "Kieu mai nha"
|
||||
label define kieumainha 1 "Be tong" 2 "Mai ngoi, ton, xi mang" 3 "Mai tranh, rom ra, giay dau" 4 "Khac"
|
||||
label values roof kieumainha
|
||||
|
||||
label variable wall "Kieu tuong"
|
||||
label define kieutuong 1 "Go" 2 "Tuong xay" 3 "Vach dat, tre, giay dau" 4 "Khac"
|
||||
label values wall kieutuong
|
||||
|
||||
label variable house_foundation "Kieu nen nha"
|
||||
label define kieunennha 1 "Go" 2 "Gach men, da hoa" 3 "Gacn lat/xi mang" 4 "Dat" 5 "Khac"
|
||||
label values house_foundation kieunennha
|
||||
|
||||
label variable water "Nguon uoc"
|
||||
label define nguonnuoc 1 "Nuoc may" 2 "Nuoc gieng khoan" 3 "Nuoc giang khoi" 4 "Nuoc mua" 5 "Nuoc ao ho" 6 "Nuoc suoi, song"
|
||||
label values water nguonnuoc
|
||||
|
||||
label variable toilet "Kieu toilet"
|
||||
label define kieutoilet 1 "Tu hoai/ban tu hoai/tham doi nuoc" 2 "Hai ngan" 3 "Mot ngan" 4 "Ho xi cau" 5 "Chung voi gia xuc" 6 "Khac" 7 "Khong co"
|
||||
label values toilet kieutoilet
|
||||
|
||||
label variable bathroom "Kieu nha tam"
|
||||
label define kieunhatam 1 "Nha tam co mai" 2 "Nha tam khong co mai" 3 "Khac" 4 "Khong co"
|
||||
label values bathroom kieunhatam
|
||||
|
||||
label define cokhong 1 "Co" 0 "Khong"
|
||||
label values cabletv cokhong
|
||||
label values adsl cokhong
|
||||
|
||||
save ..\newcode\data\std_householdinfo, replace
|
||||
|
||||
|
59
Chililabdata/newcode/genstd_householdinfo_new.do
Normal file
59
Chililabdata/newcode/genstd_householdinfo_new.do
Normal file
@@ -0,0 +1,59 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use householdinfo
|
||||
sort observeid
|
||||
duplicates drop observeid, force
|
||||
merge m:1 observeid using observation, keepusing(obs_round obs_entry_date)
|
||||
keep if _merge==3
|
||||
drop _merge
|
||||
drop round
|
||||
rename obs_round round
|
||||
rename obs_entry_date visit_date
|
||||
replace visit_date = visit_date
|
||||
sort socialgpid round
|
||||
drop if round > 22
|
||||
tostring round, replace
|
||||
replace round = "00" + round if strlen(round) == 1
|
||||
replace round ="0" + round if strlen(round)==2
|
||||
gen householdkey = socialgpid + round
|
||||
drop hhinforid observeid eco_inside_sup eco_inside_suptd eco_outside_sup eco_outside_suptd
|
||||
duplicates drop householdkey, force
|
||||
merge 1:1 householdkey using ..\newcode\data\std_househead, keepusing(househeadid)
|
||||
drop if _merge ==2
|
||||
drop responsorID entryDate fieldWrkr dataClerk deDate statusDat _merge
|
||||
sort householdkey
|
||||
/*recode*/
|
||||
label variable roof "Kieu mai nha"
|
||||
label define kieumainha 1 "Be tong" 2 "Mai ngoi, ton, xi mang" 3 "Mai tranh, rom ra, giay dau" 4 "Khac"
|
||||
label values roof kieumainha
|
||||
|
||||
label variable wall "Kieu tuong"
|
||||
label define kieutuong 1 "Go" 2 "Tuong xay" 3 "Vach dat, tre, giay dau" 4 "Khac"
|
||||
label values wall kieutuong
|
||||
|
||||
label variable house_foundation "Kieu nen nha"
|
||||
label define kieunennha 1 "Go" 2 "Gach men, da hoa" 3 "Gacn lat/xi mang" 4 "Dat" 5 "Khac"
|
||||
label values house_foundation kieunennha
|
||||
|
||||
label variable water "Nguon uoc"
|
||||
label define nguonnuoc 1 "Nuoc may" 2 "Nuoc gieng khoan" 3 "Nuoc giang khoi" 4 "Nuoc mua" 5 "Nuoc ao ho" 6 "Nuoc suoi, song"
|
||||
label values water nguonnuoc
|
||||
|
||||
label variable toilet "Kieu toilet"
|
||||
label define kieutoilet 1 "Tu hoai/ban tu hoai/tham doi nuoc" 2 "Hai ngan" 3 "Mot ngan" 4 "Ho xi cau" 5 "Chung voi gia xuc" 6 "Khac" 7 "Khong co"
|
||||
label values toilet kieutoilet
|
||||
|
||||
label variable bathroom "Kieu nha tam"
|
||||
label define kieunhatam 1 "Nha tam co mai" 2 "Nha tam khong co mai" 3 "Khac" 4 "Khong co"
|
||||
label values bathroom kieunhatam
|
||||
|
||||
label define cokhong 1 "Co" 0 "Khong"
|
||||
label values cabletv cokhong
|
||||
label values adsl cokhong
|
||||
|
||||
save ..\newcode\data\std_householdinfo_new, replace
|
||||
|
||||
|
17
Chililabdata/newcode/genstd_individual.do
Normal file
17
Chililabdata/newcode/genstd_individual.do
Normal file
@@ -0,0 +1,17 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use individual
|
||||
sort individid
|
||||
drop appround individidGuid motheridGuid fatheridGuid
|
||||
replace birthdate = birthdate/86400000
|
||||
format birthdate %td
|
||||
destring ethnicid, replace
|
||||
label define ethnic 1 "1. Kinh" 2 "2. San diu" 3 "3. Tay" 4 "4. Hoa" 5 "5. Khac" 6 "6. Thai" 7 "7. Kho me" 8 "8. Man" 9 "4. Tho"
|
||||
label values ethnic ethnic
|
||||
rename gender sex
|
||||
rename ind_name fullname
|
||||
destring sex, replace
|
||||
label define sexs 1 "1. Nam" 2 "2. Nu"
|
||||
label values sex sexs
|
||||
sort individid
|
||||
save ..\newcode\data\std_individual, replace
|
12
Chililabdata/newcode/genstd_inmigration.do
Normal file
12
Chililabdata/newcode/genstd_inmigration.do
Normal file
@@ -0,0 +1,12 @@
|
||||
clear
|
||||
cd c:\chililabdata\data
|
||||
use inmigration
|
||||
replace img_date=img_date/86400000
|
||||
format img_date %td
|
||||
gen round = substr(observeid, 10,3)
|
||||
gen socialkey = socialgpid+ round
|
||||
gen individkey = individid+ round
|
||||
drop EID socialgpidGuid eventid observeid
|
||||
duplicates drop individkey, force
|
||||
sort individkey
|
||||
save ..\newcode\data\std_inmigration, replace
|
38
Chililabdata/newcode/genstd_marstatus.do
Normal file
38
Chililabdata/newcode/genstd_marstatus.do
Normal file
@@ -0,0 +1,38 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use indmarstatus
|
||||
rename mar_sobserveid observeid
|
||||
sort individid observeid
|
||||
duplicates drop individid observeid, force
|
||||
merge m:1 observeid using observation, keepusing(obs_round obs_entry_date)
|
||||
keep if _merge==3
|
||||
drop _merge
|
||||
rename obs_round round
|
||||
rename obs_entry_date visit_date
|
||||
sort individid round
|
||||
gen rounds =0
|
||||
replace rounds = round[_n+1] if individid[_n]==individid[_n+1]
|
||||
replace rounds =23 if rounds ==0
|
||||
gen period = rounds -round
|
||||
expand period
|
||||
sort individid round
|
||||
egen minround = min(round), by (individid)
|
||||
by individid: gen step=_n-1
|
||||
replace round = minround + step
|
||||
drop if round > 22
|
||||
tostring round, replace
|
||||
replace round = "00" + round if strlen(round) == 1
|
||||
replace round ="0" + round if strlen(round)==2
|
||||
gen individkey = individ + round
|
||||
drop mar_episodeid mar_eobserveid observeid rounds period minround step
|
||||
label variable marstatusid "Tinh trang hon nhan"
|
||||
recode marstatusid (0=0)(1 6 = 1) (2/4 = 2) (5=3)
|
||||
label define marstatus 0 "0. Khong biet" 1 "1. Song cung vo/chong" 2 "2. Ly than/Ly di/Goa" 3 "3. Doc than"
|
||||
label values marstatusid marstatus
|
||||
|
||||
sort individkey
|
||||
save ..\newcode\data\std_marstatus, replace
|
||||
|
39
Chililabdata/newcode/genstd_medinsurance.do
Normal file
39
Chililabdata/newcode/genstd_medinsurance.do
Normal file
@@ -0,0 +1,39 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use medinsurance
|
||||
rename hin_sobserveid observeid
|
||||
sort individid observeid
|
||||
duplicates drop individid observeid, force
|
||||
merge m:1 observeid using observation, keepusing(obs_round obs_entry_date)
|
||||
keep if _merge==3
|
||||
drop _merge
|
||||
rename obs_round sround
|
||||
duplicates drop individid sround, force
|
||||
rename obs_entry_date visit_date
|
||||
replace visit_date = visit_date/86400000
|
||||
format visit_date %td
|
||||
sort individid sround
|
||||
gen eround =0
|
||||
replace eround = sround[_n+1] if individid[_n]==individid[_n+1]
|
||||
replace eround =23 if eround ==0
|
||||
gen period = eround -sround
|
||||
expand period
|
||||
sort individid sround
|
||||
egen minround = min(sround), by (individid)
|
||||
by individid: gen step=_n-1
|
||||
gen round = minround + step
|
||||
tostring round, replace
|
||||
replace round = "00" + round if strlen(round) == 1
|
||||
replace round ="0" + round if strlen(round)==2
|
||||
gen individkey = individ + round
|
||||
drop ins_episodeid hin_eobserveid observeid eround period minround step sround
|
||||
sort individkey
|
||||
destring hinsid, replace
|
||||
label define hin 0 "0. Khong co" 1 "1. Chinh sach" 2 "2. Bat buoc" 3 "3. Hoc sinh" 4 "4. Tu nguyen" 5 "5. Nguoi ngheo" 6 "6. Tre em" 7 "7. khac"
|
||||
label values hinsid hin
|
||||
save ..\newcode\data\std_medinsurance, replace
|
||||
|
||||
|
105
Chililabdata/newcode/genstd_membership.do
Normal file
105
Chililabdata/newcode/genstd_membership.do
Normal file
@@ -0,0 +1,105 @@
|
||||
clear all
|
||||
cd ..\data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use membership.dta
|
||||
gen observeid = mem_sobserveid
|
||||
gen sround = substr( mem_sobserveid, 10,3)
|
||||
destring sround, replace
|
||||
drop mem_sobserveidGuid mem_eobserveidGuid socialgpidGuid
|
||||
gen eround ="023" if mem_eobserveid==""
|
||||
replace eround = substr( mem_eobserveid, 10,3) if mem_eobserveid !=""
|
||||
destring(eround), replace
|
||||
duplicates drop individid mem_sobserveid,force
|
||||
duplicates drop individid eround,force
|
||||
gen period = eround - sround
|
||||
expand period
|
||||
sort individid socialgpid sround
|
||||
by individid socialgpid sround: gen step=_n-1
|
||||
gen round = sround + step
|
||||
duplicates drop individid round, force
|
||||
drop if round > 22
|
||||
tostring round, replace
|
||||
replace round = "00" + round if strlen(round) == 1
|
||||
replace round ="0" + round if strlen(round)==2
|
||||
gen individkey = individid + round
|
||||
gen householdkey = socialgpid + round
|
||||
save ..\newcode\data\std_membership1, replace
|
||||
|
||||
merge m:1 observeid using observation, keepusing(locationid)
|
||||
keep if _merge ==3
|
||||
drop _merge observeid mem_episodeid mem_sobserveid mem_seventtype mem_eobserveid mem_eeventtype mem_no sround eround period step mem_sdate mem_edate
|
||||
/* get individual core information */
|
||||
sort individid
|
||||
merge m:1 individid using ..\newcode\data\std_individual
|
||||
keep if _merge ==3
|
||||
drop _merge
|
||||
|
||||
/* get education information */
|
||||
sort individkey
|
||||
merge 1:1 individkey using ..\newcode\data\std_education.dta
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
|
||||
/* get occupation information */
|
||||
sort individkey
|
||||
merge 1:1 individkey using ..\newcode\data\std_occupation.dta
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
|
||||
/* get marial status information */
|
||||
sort individkey
|
||||
merge 1:1 individkey using ..\newcode\data\std_marstatus.dta
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
|
||||
/* get religion information */
|
||||
sort individkey
|
||||
merge 1:1 individkey using ..\newcode\data\std_religion.dta
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
|
||||
/* get marriage information */
|
||||
sort individkey
|
||||
merge 1:1 individkey using ..\newcode\data\std_relationship.dta, keepusing(partnerid marriagedate marriagetype)
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
replace marstatusid = 1 if marriagetype =="MAR"
|
||||
|
||||
/* get Insurance information */
|
||||
sort individkey
|
||||
merge 1:1 individkey using ..\newcode\data\std_medinsurance.dta, keepusing(hinsid)
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
|
||||
/* get househead information */
|
||||
sort individkey
|
||||
merge 1:1 individkey using ..\newcode\data\std_househeadlist
|
||||
keep if _merge!=2
|
||||
gen ishousehead =0
|
||||
replace ishousehead =0 if _merge ==1
|
||||
replace ishousehead =1 if _merge==3
|
||||
drop _merge
|
||||
|
||||
sort individid
|
||||
merge m:1 individid using ..\newcode\data\std_enterexit
|
||||
keep if _merge!=2
|
||||
drop _merge
|
||||
label drop _merge
|
||||
gen CommuneId = substr(locationid, 1,2)
|
||||
|
||||
/* recode */
|
||||
label variable sex "Gioi tinh"
|
||||
label variable socialgpid "Ma ho"
|
||||
label variable fatherid "Ma so bo"
|
||||
label variable motherid "Ma so me"
|
||||
label variable hinsid "Bao hiem y te"
|
||||
label variable ishousehead "La chu ho"
|
||||
label define chuho 1 "La chu ho" 0 "Khong la chu ho"
|
||||
label values ishousehead chuho
|
||||
label variable marriagetype "Hinh thuc hon nhan"
|
||||
label variable CommuneId "Ma xa"
|
||||
|
||||
|
||||
save ..\newcode\data\std_membership, replace
|
38
Chililabdata/newcode/genstd_occupation.do
Normal file
38
Chililabdata/newcode/genstd_occupation.do
Normal file
@@ -0,0 +1,38 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use occupation
|
||||
rename occ_sobserveid observeid
|
||||
sort individid observeid
|
||||
duplicates drop individid observeid, force
|
||||
merge m:1 observeid using observation, keepusing(obs_round obs_entry_date)
|
||||
keep if _merge==3
|
||||
drop _merge
|
||||
rename obs_round round
|
||||
duplicates drop individid round, force
|
||||
rename obs_entry_date visit_date
|
||||
sort individid round
|
||||
gen rounds =0
|
||||
replace rounds = round[_n+1] if individid[_n]==individid[_n+1]
|
||||
replace rounds =23 if rounds ==0
|
||||
gen period = rounds -round
|
||||
expand period
|
||||
sort individid round
|
||||
egen minround = min(round), by (individid)
|
||||
by individid: gen step=_n-1
|
||||
replace round = minround + step
|
||||
tostring round, replace
|
||||
replace round = "00" + round if strlen(round) == 1
|
||||
replace round ="0" + round if strlen(round)==2
|
||||
gen individkey = individ + round
|
||||
drop occ_episodeid occ_eobserveid observeid rounds period minround step
|
||||
sort individkey
|
||||
destring occupationid , replace
|
||||
*recode occupationid (1= 1) (6 = 2) (5 = 3) (2/4=4) (7/13=4) (0=4)
|
||||
*label define Occupation 1 "1. Làm ruong" 2 "2. Huu tri" 3 "3. Buon ban dich vu" 4 "4. Khac"
|
||||
label define Occupation 1 "1. Làm ruong" 2 "2. Vien chuc/cong chuc" 3 "3. Cong nhan" 4 "4. Thu cong" 5 "5. Buon ban/dich vu" 6 "6. Huu" 7 "7. Con nho" 8 "8. Hoc sinh/sinh vien" 9 "9. Noi tro" 10 "10. That nghiep" 11 "11. Gia yeu" 12 "12. Hoc nghe/hoc viec" 13 "13. Khac" 0 "0. Khong biet"
|
||||
label values occupationid Occupation
|
||||
save ..\newcode\data\std_occupation, replace
|
||||
|
12
Chililabdata/newcode/genstd_outmigration.do
Normal file
12
Chililabdata/newcode/genstd_outmigration.do
Normal file
@@ -0,0 +1,12 @@
|
||||
clear
|
||||
cd c:\chililabdata\data
|
||||
use outmigration
|
||||
replace out_date=out_date/86400000
|
||||
format out_date %td
|
||||
gen round = substr(observeid, 10,3)
|
||||
gen socialkey = socialgpid+ round
|
||||
gen individkey = individid+ round
|
||||
drop EID socialgpidGuid eventid observeid
|
||||
duplicates drop individkey, force
|
||||
sort individkey
|
||||
save ..\newcode\data\std_outmigration, replace
|
53
Chililabdata/newcode/genstd_pregnance.do
Normal file
53
Chililabdata/newcode/genstd_pregnance.do
Normal file
@@ -0,0 +1,53 @@
|
||||
clear
|
||||
cd c:\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)
|
||||
gen round = substr(sobserveid,10,3)
|
||||
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 householdkey = socialgpid + round
|
||||
gen individkey = individid+ round
|
||||
drop eventid sobserveid EID fatheridGuid fatherid eobserveid
|
||||
sort individkey
|
||||
/* Recode - Label */
|
||||
|
||||
label variable edate "Ngay ket thuc thai san"
|
||||
label variable sdate "Ngay bat dau thai san"
|
||||
label variable individid "Ma ca nhan"
|
||||
label variable embexemdate1 "Kham thai lan 1"
|
||||
label variable embexemdate2 "Kham thai lan 2"
|
||||
label variable embexemdate3 "Kham thai lan 3"
|
||||
label variable embexemdate4 "Kham thai lan 4"
|
||||
label variable embexemdate5 "Kham thai lan 5"
|
||||
label variable embexemdate6 "Kham thai lan 6"
|
||||
label variable embexemdate7 "Kham thai lan 7"
|
||||
label variable embexemdate8 "Kham thai lan 8"
|
||||
label variable embexemdate9 "Kham thai lan 9"
|
||||
label variable preg_inject "So mui tiem chung"
|
||||
label variable preg_etype "Su kien ket thuc thai san"
|
||||
label variable embriodur "Thoi gian mang thai"
|
||||
label variable totallivebirth "So tre sinh song"
|
||||
label variable totalborn "So tre sinh ra"
|
||||
label variable totalchildren "So con con song"
|
||||
label variable EmbrioNo "So lan mang thai"
|
||||
label variable AbortComp "Bien chung"
|
||||
label variable socialgpid "Ma ho "
|
||||
label define tiemchung 1 "Chua tiem mui nao" 2 "Mot mui" 3 "Hai mui"
|
||||
label define sukienketthuc 1 "De thuong hoac can thiep y te" 2 "Thai chet duo 28 tuan tuoi" 3 "Nham"
|
||||
label values preg_inject tiemchung
|
||||
label values preg_etype sukienketthuc
|
||||
save ..\newcode\data\std_pregance, replace
|
27
Chililabdata/newcode/genstd_recidency.do
Normal file
27
Chililabdata/newcode/genstd_recidency.do
Normal file
@@ -0,0 +1,27 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use individres.dta
|
||||
gen sround = substr( res_sobserveid, 10,3)
|
||||
destring sround, replace
|
||||
drop res_sobserveidGuid res_eobserveidGuid
|
||||
gen eround ="023" if res_eobserveid==""
|
||||
replace eround = substr( res_eobserveid, 10,3) if res_eobserveid !=""
|
||||
destring(eround), replace
|
||||
duplicates drop individid res_sobserveid,force
|
||||
duplicates drop individid eround,force
|
||||
gen period = eround - sround
|
||||
expand period
|
||||
sort individid locationid sround
|
||||
by individid locationid sround: gen step=_n-1
|
||||
gen round = sround + step
|
||||
duplicates drop individid round, force
|
||||
drop if round > 22
|
||||
tostring round, replace
|
||||
replace round = "00" + round if strlen(round) == 1
|
||||
replace round ="0" + round if strlen(round)==2
|
||||
gen individkey = individid + round
|
||||
sort individkey
|
||||
drop res_episodeid res_seventtype res_sdate res_sobserveid res_eeventtype res_eobserveid res_edate sround eround period step
|
||||
save ..\newcode\data\std_recidency, replace
|
||||
|
||||
|
57
Chililabdata/newcode/genstd_relationship.do
Normal file
57
Chililabdata/newcode/genstd_relationship.do
Normal file
@@ -0,0 +1,57 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use relationship
|
||||
drop if individid == "" | individid == "0"
|
||||
save female_relationship, replace
|
||||
|
||||
use relationship
|
||||
rename individid individid1
|
||||
rename rel_partnerid individid
|
||||
rename individid1 rel_partnerid
|
||||
drop if individid == "" | individid == "0"
|
||||
save male_relationship, replace
|
||||
use female_relationship
|
||||
append using male_relationship
|
||||
drop if length(individid) != 11
|
||||
drop rel_partneridGuid rel_episodeid
|
||||
|
||||
rename rel_partnerid partnerid
|
||||
rename rel_sdate marriagedate
|
||||
rename rel_edate marriageedate
|
||||
rename rel_seventtype marriagetype
|
||||
rename rel_eeventtype eeventtype
|
||||
rename rel_sobserveid sobserveid
|
||||
rename rel_eobserveid eobserveid
|
||||
|
||||
gen sround = substr(sobserveid, 10,3)
|
||||
destring sround, replace
|
||||
gen eround ="023" if eobserveid==""
|
||||
replace eround = substr(eobserveid, 10,3) if eobserveid !=""
|
||||
destring(eround), replace
|
||||
|
||||
duplicates drop individid sobserveid,force
|
||||
duplicates drop individid eround,force
|
||||
gen period = eround - sround
|
||||
expand period
|
||||
sort individid partnerid sround
|
||||
by individid partnerid sround: gen step=_n-1
|
||||
gen round = sround + step
|
||||
duplicates drop individid round, force
|
||||
drop if round >=23
|
||||
tostring round, replace
|
||||
replace round = "00" + round if strlen(round) == 1
|
||||
replace round = "0" + round if strlen(round) == 2
|
||||
gen individkey = individid + round
|
||||
sort individkey
|
||||
drop sobserveid eeventtype eobserveid sround eround period step round marriageedate
|
||||
save ..\newcode\data\std_relationship, replace
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
39
Chililabdata/newcode/genstd_religion.do
Normal file
39
Chililabdata/newcode/genstd_religion.do
Normal file
@@ -0,0 +1,39 @@
|
||||
clear all
|
||||
cd c:\chililabdata\data
|
||||
use observation
|
||||
sort observeid
|
||||
save, replace
|
||||
use religion
|
||||
rename reg_sobserveid observeid
|
||||
sort individid observeid
|
||||
duplicates drop individid observeid, force
|
||||
merge m:1 observeid using observation, keepusing(obs_round obs_entry_date)
|
||||
keep if _merge==3
|
||||
drop _merge
|
||||
rename obs_round sround
|
||||
duplicates drop individid sround, force
|
||||
rename obs_entry_date visit_date
|
||||
replace visit_date = visit_date/86400000
|
||||
format visit_date %td
|
||||
sort individid sround
|
||||
gen eround =0
|
||||
replace eround = sround[_n+1] if individid[_n]==individid[_n+1]
|
||||
replace eround =23 if eround ==0
|
||||
gen period = eround -sround
|
||||
expand period
|
||||
sort individid sround
|
||||
egen minround = min(sround), by (individid)
|
||||
by individid: gen step=_n-1
|
||||
gen round = minround + step
|
||||
tostring round, replace
|
||||
replace round = "00" + round if strlen(round) == 1
|
||||
replace round ="0" + round if strlen(round)==2
|
||||
gen individkey = individ + round
|
||||
drop reg_episodeid reg_eobserveid observeid eround period minround step sround
|
||||
sort individkey
|
||||
destring religionid, replace
|
||||
label define reg 1 "1. Khong" 2 "2. Thien chua" 3 "3. Phat giao" 4 "4. Khac"
|
||||
label values religionid reg
|
||||
save ..\newcode\data\std_religion, replace
|
||||
|
||||
|
BIN
Chililabdata/newcode/householdlist.xlsx
Normal file
BIN
Chililabdata/newcode/householdlist.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user