clear all set more off set maxvar 10000 *Set path *** *cd ---- specify path to \data_replication\psid\ cd raw_data *Import data for individuals do IND2011ER.do *Generate unique id *Last three digits are the person number *ER30001-1968 Family id *ER30002-Person number gen hid=ER30001*1000+ER30002 cd .. cd proc_data save temp_master.dta,replace **************************************** *Join with data after taxsim correction *in order to assign the unique id to the *household head **************************************** *** * IMPORTANT !!! paste files from "our_proc" subfolder into the "proc_data" folder if you didn't manage to get taxsim9 to run on your computer *** *1999 use temp_master.dta,clear drop if ER33503!=10 //keep only heads in that year drop if ER33502!=1 //keep only if head is still within family unit rename ER33501 fam_ID_year joinby fam_ID_year using temp1999.dta, unmatched(both) drop if _merge!=3 drop _merge drop if age_head!=ER33504 //drop obs. that are inconsistent about the age of head drop ER* save p1999.dta, replace *2001 use temp_master.dta,clear drop if ER33603!=10 //keep only heads in that year drop if ER33602!=1 //keep only if head is still within family unit rename ER33601 fam_ID_year joinby fam_ID_year using temp2001.dta, unmatched(both) drop if _merge!=3 drop _merge drop if age_head!=ER33604 //drop obs. that are inconsistent about the age of head drop if ER33608!=0 //drop if head has moved in/out (splitoffs) drop ER* save p2001.dta, replace *2003 use temp_master.dta,clear drop if ER33703!=10 //keep only heads in that year drop if ER33702!=1 //keep only if head is still within family unit rename ER33701 fam_ID_year joinby fam_ID_year using temp2003.dta, unmatched(both) drop if _merge!=3 drop _merge drop if age_head!=ER33704 //drop obs. that are inconsistent about the age of head drop if ER33708!=0 //drop if head has moved in/out (splitoffs) drop ER* save p2003.dta, replace *2005 use temp_master.dta,clear drop if ER33803!=10 //keep only heads in that year drop if ER33802!=1 //keep only if head is still within family unit rename ER33801 fam_ID_year joinby fam_ID_year using temp2005.dta, unmatched(both) drop if _merge!=3 drop _merge drop if age_head!=ER33804 //drop obs. that are inconsistent about the age of head drop if ER33808!=0 //drop if head has moved in/out (splitoffs) drop ER* save p2005.dta, replace *2007 use temp_master.dta,clear drop if ER33903!=10 //keep only heads in that year drop if ER33902!=1 //keep only if head is still within family unit rename ER33901 fam_ID_year joinby fam_ID_year using temp2007.dta, unmatched(both) drop if _merge!=3 drop _merge drop if age_head!=ER33904 //drop obs. that are inconsistent about the age of head drop if ER33908!=0 //drop if head has moved in/out (splitoffs) drop ER* save p2007.dta, replace *2009 use temp_master.dta,clear drop if ER34003!=10 //keep only heads in that year drop if ER34002!=1 //keep only if head is still within family unit rename ER34001 fam_ID_year joinby fam_ID_year using temp2009.dta, unmatched(both) drop if _merge!=3 drop _merge drop if age_head!=ER34004 //drop obs. that are inconsistent about the age of head drop if ER34008!=0 //drop if head has moved in/out (splitoffs) drop ER* save p2009.dta, replace *2011 use temp_master.dta,clear drop if ER34103!=10 //keep only heads in that year drop if ER34102!=1 //keep only if head is still within family unit rename ER34101 fam_ID_year joinby fam_ID_year using temp2011.dta, unmatched(both) drop if _merge!=3 drop _merge drop if age_head!=ER34104 //drop obs. that are inconsistent about the age of head drop if ER34108!=0 //drop if head has moved in/out (splitoffs) drop ER* save p2011.dta, replace **************************************** *Create panel **************************************** *Adjust the names of the variables forval x=1999(2)2011{ use p`x'.dta, clear ren aftertax_income_defl_equiv inc`x' ren age_head age`x' ren ed_head edu`x' ren marital_status_head mstat`x' ren fam_ID_year fam_ID`x' ren size_fam size_fam`x' drop fam_ID_1968 year_survey //drop variables that are not useful save pk`x'.dta,replace } *Join datasets to form a panel use pk1999.dta, clear forval x=2001(2)2011{ joinby hid using pk`x'.dta, unmatched(both) drop if _merge!=3 drop _merge local i=`x'-2 di "`i'" gen b=age`x'-age`i' tab b drop if b!=2 & b!=1 & b!=3 // drop people that are inconsistent about their age (1/2/3 are consistent due to the differences in month of interview) drop b gen a=edu`x'-edu`i' tab a drop if a<0 // drop people that are inconsistent about their education (to adjust for any errors, see 2009 family codebook release info) drop a } *Reshape the data for better use reshape long inc age edu mstat fam_ID size_fam, i(hid) j(year) save for_reg.dta, replace