File size: 3,312 Bytes
2a8276b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
clear all
set more off
set maxvar 10000
*Set path
***
*cd ---- specify path to \data_replication\psid\
local procdata "./proc_data/"
local rawdata "./raw_data/"
cd proc_data
use for_reg.dta, clear
*Prepare the panel
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 ..
*###############################################################################
*Prepare the refinancing data for each year
*###############################################################################
foreach x of numlist 99 01 03 05 07 09 11{
clear
*###############################################################################
*Prepare the consumption data
*###############################################################################
if `x'==99 | `x'==11{
*Convert PSID consumption files to stata format
cd raw_data
do CON`x'.do
ren CON`x'_ID fam_ID
if `x'==99 {
gen year=19`x'
*join with income
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'
*join with income
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{
*Convert PSID consumption files to stata format
cd raw_data
do CON0`x'.do
ren CON0`x'_ID fam_ID
gen year=200`x'
*join with income
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
*Create consumption variables for each year
*note that some files contain more variables
*1999
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
*2001 and 2003
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
}
*2005,2007 and 2009
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
}
*2011
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
|