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 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
|
|
|
|
|