// Code for "Saving Behavior and Housing Wealth - Evidence from German Micro Data" by S. Gröbel and D. Ihle // Preparing the data: Start cd "H:\...\Datensaetze" //Enter the preferred path here use hmaster_hw_panel, clear *ab 1994 drop if jahr==1992 drop if jahr==1993 *Beobachtungen rausschmeissen ohne Interview (unbalanced panel) drop if hnetto!=1 drop hnetto /* Ersparnisse */ replace savings=. if savings==-1 replace savings=. if savings==-3 replace savings=0 if savings==-2 // Bis 2001 erfolgte Erhebung aller monetären Variablen in DM, ab dem Erhbungsjahr 2002 in EURO. Aus Konsistenzgründen werden alle Angaben auch für 1994-2001 in Euro ausgewiesen (1Euro=1.95583DM) // *Umrechnung DM in EURO replace savings=savings/1.95583 if jahr<2002 *deflationieren replace savings=(savings*cpi)/100 *Ersparnis pro Jahr gen ysavings=savings*12 *logarithmierte (jaehrliche) Ersparnis gen lnsavings=ln(savings) gen lnysavings=ln(ysavings) *1.Differenzen sort hhnrakt jahr by hhnrakt: gen D_lnsavings=D.lnsavings sort hhnrakt jahr by hhnrakt: gen D_lnysavings=D.lnysavings replace sav=. if sav==-2 replace sav=. if sav==-1 /* Einkommen */ replace netinc=. if netinc==-1 replace netinc=. if netinc==-3 *Einkommen in Euro umrechnen replace netinc=netinc/1.95583 if jahr<2002 *Einkommen deflationieren gen realnetinc=(netinc*cpi)/100 *Einkommen auf Jahresbasis "hochrechnen" gen ynetinc=netinc*12 gen realynetinc=(ynetinc*cpi)/100 *Logarithmus gen lnrealnetinc=ln(realnetinc) gen lnrealynetinc=ln(realynetinc) *1.Differenz sort hhnrakt jahr by hhnrakt: gen D_lnrealnetinc=D.lnrealnetinc sort hhnrakt jahr by hhnrakt: gen D_lnrealynetinc=D.lnrealynetinc *Logarithmiertes Lag-Einkommen sort hhnrakt jahr by hhnrakt: gen L_lnrealnetinc=l.lnrealnetinc by hhnrakt: gen L_lnrealynetinc=l.lnrealynetinc /*Interpolation des Finanzvermögens */ by hhnrakt: ipolate financial jahr, gen(ifinancial) epolate by hhnrakt: gen state=0 by hhnrakt: replace state=1 if financial!=. by hhnrakt (jahr), sort: gen noccur = sum(state) by hhnrakt (jahr): gen byte first = noccur == 1 & noccur[_n-1] != noccur by hhnrakt: gen financial_ersatz=financial if first==1 by hhnrakt: egen financial_ersatz2=total(financial_ersatz) by hhnrakt: replace financial_ersatz2=. if ifinancial==. by hhnrakt: replace noccur=. if ifinancial==. by hhnrakt: replace ifinancial=financial_ersatz2 if noccur==0 drop state noccur first financial_ersatz financial_ersatz2 *negatives Finanzvermögen (welches nur durch die Interpolation entstanden ist, vorher war Min=0) wird auf 0 gesetzt replace ifinancial=0 if ifinancial<0 *Finanzvermögen deflationieren gen realifinancial=(ifinancial*cpi)/100 *Veraenderung Finanzvermögen sort hhnrakt jahr by hhnrakt: gen D_ifinancial=D.ifinancial /*Interpolation des Sachvermögens*/ by hhnrakt: ipolate tangible jahr, gen(itangible) epolate by hhnrakt: gen state=0 by hhnrakt: replace state=1 if tangible!=. by hhnrakt (jahr), sort: gen noccur = sum(state) by hhnrakt (jahr): gen byte first = noccur == 1 & noccur[_n-1] != noccur by hhnrakt: gen tangible_ersatz=tangible if first==1 by hhnrakt: egen tangible_ersatz2=total(tangible_ersatz) by hhnrakt: replace tangible_ersatz2=. if tangible==. by hhnrakt: replace noccur=. if tangible==. by hhnrakt: replace itangible=tangible_ersatz2 if noccur==0 drop state noccur first tangible_ersatz tangible_ersatz2 *negatives Sachvermögen (welches nur durch die Interpolation entstanden ist, vorher war Min=0) wird auf 0 gesetzt replace itangible=0 if itangible<0 *Sachvermögen deflationieren gen realitangible=(itangible*cpi)/100 /*Konsumausgaben*/ gen yexp=realynetinc-D_ifinancial gen exp2=realnetinc-savings gen yexp2=realynetinc-ysavings *logarithmieren gen lnyexp2=ln(yexp2) *1.Differenz gen D_lnyexp2=D.lnyexp2 /* Wohnausgaben */ replace modexp=. if modexp==-1 | modexp==-3 | modexp==-2 replace zinsexp=. if zinsexp==-1 | zinsexp==-3 | zinsexp==-2 replace maintexp=. if maintexp==-1 | maintexp==-3 | maintexp==-2 replace operexp=. if operexp==-1 | operexp==-3 | operexp==-2 *in Euro umrechnen replace zinsexp=zinsexp/1.95583 if jahr<2002 replace maintexp=maintexp/1.95583 if jahr<2002 replace operexp=operexp/1.95583 if jahr<2002 *auf das Jahr hochrechnen gen yzinsexp=zinsexp*12 *deflationieren gen realmodexp=(modexp*cpi)/100 gen realyzinsexp=(yzinsexp*cpi)/100 gen realmaintexp=(maintexp*cpi)/100 gen realoperexp=(operexp*cpi)/100 sort hhnrakt jahr gen realmaintexp_f=f.realmaintexp gen realoperexp_f=f.realoperexp gen realhousingexp=realmaintexp_f+realoperexp_f gen realhousingexp2=realhousingexp+realyzinsexp *für 2010-2012 mit Modernisierungskosten gen realhousingexp3=realhousingexp2+realmodexp /*Vermoegen*/ gen nethw=netprop+netotherprop gen netnonhw=netwealth-nethw /* Alter */ replace age=. if age==-1 *logarithmiertes Alter gen lnage=ln(age) gen lnage2=lnage*lnage *Alterskategorien bilden mit 3 Klassen - als Dummy gen young=(age<=35) gen middle=(age>35 & age<=60) gen old=(age>60 & age !=.) *Eine Variable mit Kategorien gen ageKat=. replace ageKat=1 if young==1 replace ageKat=2 if middle==1 replace ageKat=3 if old==1 tab ageKat *Values der Kategorien definieren label define agekat 1 "young" 2 "middle" 3 "old" label values ageKat agekat *Alterskategorien bilden mit 2 Klassen - als Dummy gen young2=1 if age<=40 & age!=. replace young2=0 if age>40 & age!=. gen old2=1 if age>40 & age!=. replace old2=0 if age<=40 & age!=. gen ageKat2=. replace ageKat2=1 if young2==1 replace ageKat2=0 if old2==1 *Values der Kategorien definieren label define agekat2 1 "young" 2 "old" label values ageKat2 agekat2 *Robustness check: Alterskategorien mit Grenze bei 45 Jahren gen young3=1 if age<=45 & age!=. replace young3=0 if age>45 & age!=. gen old3=1 if age>45 & age!=. replace old3=0 if age<=45 & age!=. *Robustness check: Alterskategorien mit Grenze bei 50 Jahren gen young4=1 if age<=50 & age!=. replace young4=0 if age>50 & age!=. gen old4=1 if age>50 & age!=. replace old4=0 if age<=50 & age!=. /* Variablen Kategorisierung */ gen homeowner=owner replace homeowner=. if owner==-1 replace homeowner=2 if owner==3 replace homeowner=2 if owner==4 replace homeowner=2 if owner==5 gen dho=(homeowner==1) gen drenter=(homeowner==2) gen married=marital replace married=. if marital==-1 replace married=1 if marital==1 | marital==3 replace married=2 if marital==2 | marital==4 | marital==5 | marital==6 replace marital=. if marital==-1 gen kids=. replace kids=0 if numberkids==0 replace kids=1 if numberkids==1 replace kids=2 if numberkids==2 replace kids=3 if numberkids>=3 replace kred=. if kred==-3 | kred==-1 replace kredit=. if kredit==-1 | kredit==-3 replace kredit=0 if kredit==-2 //(trifft nicht zu) replace belastung_kr=. if belastung_kr==-1 replace employ=. if employ==-1 replace educ=. if educ==-1 /* Jahres- und Regionsdummies */ gen d95=(jahr==1995) gen d96=(jahr==1996) gen d97=(jahr==1997) gen d98=(jahr==1998) gen d99=(jahr==1999) gen d00=(jahr==2000) gen d01=(jahr==2001) gen d02=(jahr==2002) gen d03=(jahr==2003) gen d04=(jahr==2004) gen d05=(jahr==2005) gen d06=(jahr==2006) gen d07=(jahr==2007) gen d08=(jahr==2008) gen d09=(jahr==2009) gen d10=(jahr==2010) gen d11=(jahr==2011) gen d12=(jahr==2012) gen dror1=(ror_id==1) gen dror3=(ror_id==3) gen dror4=(ror_id==4) gen dror6=(ror_id==6) gen dror7=(ror_id==7) gen dror8=(ror_id==8) gen dror11=(ror_id==11) gen dror12=(ror_id==12) gen dror13=(ror_id==13) gen dror16=(ror_id==16) gen dror18=(ror_id==18) gen dror22=(ror_id==22) gen dror27=(ror_id==27) gen dror28=(ror_id==28) gen dror29=(ror_id==29) gen dror30=(ror_id==30) gen dror32=(ror_id==32) gen dror34=(ror_id==34) gen dror35=(ror_id==35) gen dror36=(ror_id==36) gen dror39=(ror_id==39) gen dror40=(ror_id==40) gen dror41=(ror_id==41) gen dror42=(ror_id==42) gen dror43=(ror_id==43) gen dror44=(ror_id==44) gen dror46=(ror_id==46) gen dror48=(ror_id==48) gen dror51=(ror_id==51) gen dror52=(ror_id==52) gen dror54=(ror_id==54) gen dror55=(ror_id==55) gen dror56=(ror_id==56) gen dror57=(ror_id==57) gen dror58=(ror_id==58) gen dror60=(ror_id==60) gen dror62=(ror_id==62) gen dror63=(ror_id==63) gen dror64=(ror_id==64) gen dror65=(ror_id==65) gen dror66=(ror_id==66) gen dror68=(ror_id==68) gen dror69=(ror_id==69) gen dror70=(ror_id==70) gen dror71=(ror_id==71) gen dror72=(ror_id==72) gen dror74=(ror_id==74) gen dror77=(ror_id==77) gen dror80=(ror_id==80) gen dror81=(ror_id==81) gen dror82=(ror_id==82) gen dror83=(ror_id==83) gen dror84=(ror_id==84) gen dror86=(ror_id==86) gen dror88=(ror_id==88) gen dror89=(ror_id==89) gen dror90=(ror_id==90) gen dror91=(ror_id==91) gen dror92=(ror_id==92) gen dror93=(ror_id==93) gen dror95=(ror_id==95) gen dror97=(ror_id==97) *Liquiditätsdummy gen liquidity=1.5*realnetinc by hhnrakt: gen dlowliquidity=1 if realitangible=liquidity & realitangible!=. & liquidity!=. /* HAUSPREISE */ *Hauspreise logarithmieren und 1.Differenzen bilden gen lnprice=ln(price) by hhnrakt: gen D_lnprice=D.lnprice *** ab Jahr 1996 (da Längsschnittstudie aufgrund von ROR erst ab 1996 möglich) drop if jahr==1994 drop if jahr==1995 save "H:\...\hmaster_hwpanel_bearbeitet96", replace //Enter the preferred path here /* mergen mit aktuellen, erwarteten, unerwarteten HP */ cd "H:\...\Datensaetze" //Enter the preferred path here use hmaster_hwpanel_bearbeitet96, clear merge m:1 jahr ror_id using act_exp_unexp_hp.dta drop if _merge==2 drop _merge sort hhnrakt jahr gen y_act=D_lnrealynetinc save "H:\...\hmaster_hwpanel_bearbeitet96", replace //Enter the preferred path here /* mergen mit Populationswachstum */ cd "H:\...\Datensaetze" //Enter the preferred path here use hmaster_hwpanel_bearbeitet96, clear merge m:1 ror_id using dummies_popgrowth.dta drop if _merge==2 drop _merge sort hhnrakt jahr *Interpolation der Schulden by hhnrakt: ipolate wealth_debts jahr, gen(iwealth_debts) epolate by hhnrakt: gen state=0 by hhnrakt: replace state=1 if wealth_debts!=. by hhnrakt (jahr), sort: gen noccur = sum(state) by hhnrakt (jahr): gen byte first = noccur == 1 & noccur[_n-1] != noccur by hhnrakt: gen wealth_debts_ersatz=wealth_debts if first==1 by hhnrakt: egen wealth_debts_ersatz2=total(wealth_debts_ersatz) by hhnrakt: replace iwealth_debts=wealth_debts_ersatz2 if noccur==0 drop state noccur first wealth_debts_ersatz wealth_debts_ersatz2 *negative Schulden (welche nur durch die Interpolation entstanden sind, vorher war Min=0) wird auf 0 gesetzt replace iwealth_debts=0 if iwealth_debts<0 save "H:\...\hmaster_hwpanel_bearbeitet96", replace //Enter the preferred path here /* mergen mit wahrgenommener VerŠnderung der HP */ cd "H:\...\Datensaetze" //Enter the preferred path here use hmaster_hwpanel_bearbeitet96, clear merge 1:1 hhnrakt jahr using propchange2.dta drop if _merge==2 drop _merge sort hhnrakt jahr save "H:\...\hmaster_hwpanel_bearbeitet96", replace //Enter the preferred path here // Preparing the data: Ende