40 lines
1.2 KiB
Plaintext
40 lines
1.2 KiB
Plaintext
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
|
|
|
|
|