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
|
||||
Reference in New Issue
Block a user