Uloading
Uloading
This commit is contained in:
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
|
||||
|
||||
Reference in New Issue
Block a user