Files
Dss/Chililabdata/newcode/genstd_education.do
admin 8c43da1d1c Uloading
Uloading
2025-08-02 05:26:16 +07:00

39 lines
1.1 KiB
Plaintext

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