|
|
| clear all
|
| set more off
|
| set maxvar 10000
|
|
|
|
|
|
|
|
|
|
|
|
|
| local procdata "./proc_data/"
|
| local rawdata "./raw_data/"
|
|
|
| cd proc_data
|
|
|
| use for_reg.dta, clear
|
|
|
|
|
| drop if age<25 & year==1999
|
| drop if age>85 & year==2011
|
| bys hid: gen nyear=[_N]
|
| keep if nyear==7
|
|
|
| keep fam_ID year hid
|
| save income_panel2.dta, replace
|
|
|
| cd ..
|
|
|
|
|
|
|
|
|
|
|
| foreach x of numlist 99 01 03 05 07 09 11{
|
| clear
|
|
|
|
|
|
|
|
|
| if `x'==99 | `x'==11{
|
|
|
| cd raw_data
|
| do CON`x'.do
|
| ren CON`x'_ID fam_ID
|
| if `x'==99 {
|
| gen year=19`x'
|
|
|
| cd ..
|
| joinby fam_ID year using `procdata'income_panel2.dta, unmatched(both)
|
| drop if _merge!=3
|
| drop _merge
|
| save `procdata'cons_temp19`x'.dta,replace
|
| }
|
| else{
|
| gen year=20`x'
|
|
|
| cd ..
|
| joinby fam_ID year using `procdata'income_panel2.dta, unmatched(both)
|
| drop if _merge!=3
|
| drop _merge
|
| save `procdata'cons_temp20`x'.dta,replace
|
| }
|
| }
|
| else{
|
|
|
| cd raw_data
|
| do CON0`x'.do
|
| ren CON0`x'_ID fam_ID
|
| gen year=200`x'
|
|
|
| cd ..
|
| joinby fam_ID year using `procdata'income_panel2.dta, unmatched(both)
|
| drop if _merge!=3
|
| drop _merge
|
| save `procdata'cons_temp200`x'.dta,replace
|
|
|
| }
|
| }
|
|
|
|
|
| cd proc_data
|
|
|
|
|
|
|
| use cons_temp1999.dta, clear
|
| gen food_cons=FOOD99
|
| gen rent_cons=RENT99
|
| gen util_cons=UTIL99
|
| gen tran_cons=TRAN99
|
| gen educ_cons=ED99
|
| gen kids_cons=CHILD99
|
| gen heal_cons=HEALTH99
|
| keep food_cons rent_cons util_cons tran_cons educ_cons kids_cons heal_cons hid year
|
| save cons1999.dta, replace
|
|
|
| forval x=2001(2)2003{
|
| local i=`x'-2000
|
| use cons_temp200`i'.dta, clear
|
| gen food_cons=FOOD0`i'
|
| gen rent_cons=RENT0`i'
|
| gen util_cons=UTIL0`i'
|
| gen tran_cons=TRAN0`i'
|
| gen educ_cons=ED0`i'
|
| gen kids_cons=CHILD0`i'
|
| gen heal_cons=HEALTH0`i'
|
| keep food_cons rent_cons util_cons tran_cons educ_cons kids_cons heal_cons hid year
|
| save cons`x'.dta, replace
|
| }
|
|
|
| forval x=2005(2)2009{
|
| local i=`x'-2000
|
| use cons_temp200`i'.dta, clear
|
| gen food_cons=FOOD0`i'
|
| gen rent_cons=RENT0`i'
|
| gen util_cons=UTIL0`i'
|
| gen tran_cons=TRAN0`i'
|
| gen educ_cons=ED0`i'
|
| gen kids_cons=CHILD0`i'
|
| gen heal_cons=HEALTH0`i'
|
| gen other_cons=TELINT0`i'+CLOTH0`i'+TRIPS0`i'+OTHREC0`i'
|
| keep food_cons rent_cons util_cons tran_cons educ_cons kids_cons heal_cons hid year other_cons
|
| save cons`x'.dta, replace
|
| }
|
|
|
| use cons_temp2011.dta, clear
|
| gen food_cons=FOOD11
|
| gen rent_cons=RENT11
|
| gen util_cons=UTIL11
|
| gen tran_cons=TRAN11
|
| gen educ_cons=ED11
|
| gen kids_cons=CHILD11
|
| gen heal_cons=HEALTH11
|
| gen other_cons=TELINT11+CLOTH11+TRIPS11+OTHREC11
|
| keep food_cons rent_cons util_cons tran_cons educ_cons kids_cons heal_cons hid year other_cons
|
| save cons2011.dta, replace
|
|
|
|
|
|
|