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

39 lines
1.5 KiB
Plaintext

clear all
cd c:\chililabdata\data
use observation
sort observeid
save, replace
use occupation
rename occ_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 occ_episodeid occ_eobserveid observeid rounds period minround step
sort individkey
destring occupationid , replace
*recode occupationid (1= 1) (6 = 2) (5 = 3) (2/4=4) (7/13=4) (0=4)
*label define Occupation 1 "1. Làm ruong" 2 "2. Huu tri" 3 "3. Buon ban dich vu" 4 "4. Khac"
label define Occupation 1 "1. Làm ruong" 2 "2. Vien chuc/cong chuc" 3 "3. Cong nhan" 4 "4. Thu cong" 5 "5. Buon ban/dich vu" 6 "6. Huu" 7 "7. Con nho" 8 "8. Hoc sinh/sinh vien" 9 "9. Noi tro" 10 "10. That nghiep" 11 "11. Gia yeu" 12 "12. Hoc nghe/hoc viec" 13 "13. Khac" 0 "0. Khong biet"
label values occupationid Occupation
save ..\newcode\data\std_occupation, replace