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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552


clear all
set more off
set maxvar 10000
set mem 500m

*Set path
***
*cd ---- specify path to \data_replication\scf\proc_data\
local ourprocdata  "./our_proc"
local output "./output"

use taxsim2001.dta, clear
*use our processed data
*use "`ourprocdata'/taxsim2001.dta", clear


****************************************************************************************
****************************************************************************************

*Rent
rename X708 rent
rename X709 per_rent
replace rent=rent*12 if per_rent==4 //monthly
replace rent=rent*12*4.34 if per_rent==2 //weekly
replace rent=rent*12*2.17 if per_rent==3 //biweekly
replace rent=rent*4 if per_rent==5 //quarterly
replace rent=rent*2 if per_rent==11 //twice per year
replace rent=rent*6 if per_rent==12 //every two months
replace rent=rent*12*2 if per_rent==31 //twice a month
replace rent=. if per_rent==-1 //none
replace rent=. if per_rent==-7 //other

gen HELS=cond(X1005-X1004>0,0,max(X1005,0)) // some people report more debt than they took initially

*Create year first mortgage was taken
rename X802 year_main_mtg 
rename X902 year_main_mtg2 
rename X1002 year_main_mtg3
replace year_main_mtg=. if year_main_mtg==0
gen mtg_age = 2001 - year_main_mtg

replace year_main_mtg2=. if year_main_mtg2==0
replace year_main_mtg3=. if year_main_mtg3==0

gen mtg_age2=(2001-year_main_mtg2)
gen mtg_age3=(2001-year_main_mtg3)



*Create number of years agreed for payment for first mortgage
rename X806 nr_years_mtg_at_origin
replace nr_years_mtg_at_origin=. if nr_years_mtg_at_origin<=0


*Clean
drop J*
drop X*



********************************************************************************
*Create wealth variables
********************************************************************************
*Value of all houses
replace houses=. if houses<0
replace oresre=. if oresre<0
gen house_val=houses
*Homeownership status
gen ownership=housecl

*liquid assets
gen l_assets=max(othfin,0)+max(checking,0)+max(saving,0)+max(mma,0)+max(cds,0)+max(nmmf,0)+max(savbnd,0)+max(stocks,0)+max(bond,0)+oresre+nnresre   // oresre includes land contracts/notes, while nnresre doesn't

*mortgage debt
gen m_debt=max(NH_MORT,0)-max(HELS,0)
drop m_debt
gen m_debt=max(NH_MORT,0)+max(heloc,0)

*HELOC
gen helocs=max(heloc,0)+max(HELS,0)

*liquid debt
gen l_debt=max(ccbal,0)+max(resdbt,0)

*Wealth (net worth)
gen wealth=house_val+l_assets-l_debt-m_debt
gen hnworth=house_val-m_debt

*Age of head
gen age_head=age

*Generate positive house values
gen h1=house_val if house_val>=0

******
replace inc=inc/equiv
replace h1=h1/equiv
******

******************************
*Drop observation with wealth above 80th percentile
******************************
pctile pct = wealth [w=wgt], nq(100) genp(percent)
gen pk1=pct if percent==80
egen mean_pk1=mean(pk1)
drop if wealth>mean_pk1

*Drop households that are too young or too old
drop if age_head<25
drop if age_head>85

********************************************************************************************************************************************

********
*Panel A
********

*mean income (25-30) / mean income (all)  
preserve
egen meanpop = wtmean(inc), weight(wgt)
collapse (mean) inc (mean) meanpop [weight=wgt] if age_head<=30
gen res=inc/meanpop
gen title="mean income (25-30) / mean income (all)"
save moment1.dta, replace
restore 

*mean income (31-35) / mean income (all)  
preserve
egen meanpop = wtmean(inc), weight(wgt)
collapse (mean) inc (mean) meanpop [weight=wgt] if (age_head>30) & (age_head<=35)
gen res=inc/meanpop
gen title="mean income (31-35) / mean income (all)"
save moment2.dta, replace
restore 

*mean income (36-40) / mean income (all)  
preserve
egen meanpop = wtmean(inc), weight(wgt)
collapse (mean) inc (mean) meanpop [weight=wgt] if (age_head>35) & (age_head<=40)
gen res=inc/meanpop
gen title="mean income (36-40) / mean income (all)"
save moment3.dta, replace
restore 

*mean income (41-45) / mean income (all)  
preserve
egen meanpop = wtmean(inc), weight(wgt)
collapse (mean) inc (mean) meanpop [weight=wgt] if (age_head>40) & (age_head<=45)
gen res=inc/meanpop
gen title="mean income (41-45) / mean income (all)"
save moment4.dta, replace
restore 

*mean income (46-50) / mean income (all)  
preserve
egen meanpop = wtmean(inc), weight(wgt)
collapse (mean) inc (mean) meanpop [weight=wgt] if (age_head>45) & (age_head<=50)
gen res=inc/meanpop
gen title="mean income (46-50) / mean income (all)"
save moment5.dta, replace
restore

*mean income (51-55) / mean income (all)  
preserve
egen meanpop = wtmean(inc), weight(wgt)
collapse (mean) inc (mean) meanpop [weight=wgt] if (age_head>50) & (age_head<=55)
gen res=inc/meanpop
gen title="mean income (51-55) / mean income (all)"
save moment6.dta, replace
restore

*mean income (56-60) / mean income (all)  
preserve
egen meanpop = wtmean(inc), weight(wgt)
collapse (mean) inc (mean) meanpop [weight=wgt] if (age_head>55) & (age_head<=60)
gen res=inc/meanpop
gen title="mean income (56-60) / mean income (all)"
save moment7.dta, replace
restore

*mean income (61-65) / mean income (all)  
preserve
egen meanpop = wtmean(inc), weight(wgt)
collapse (mean) inc (mean) meanpop [weight=wgt] if (age_head>60) & (age_head<=65)
gen res=inc/meanpop
gen title="mean income (61-65) / mean income (all)"
save moment8.dta, replace
restore

*mean income (66-70) / mean income (all)  
preserve
egen meanpop = wtmean(inc), weight(wgt)
collapse (mean) inc (mean) meanpop [weight=wgt] if (age_head>65) & (age_head<=70)
gen res=inc/meanpop
gen title="mean income (66-70) / mean income (all)"
save moment9.dta, replace
restore

*mean income (71-75) / mean income (all)  
preserve
egen meanpop = wtmean(inc), weight(wgt)
collapse (mean) inc (mean) meanpop [weight=wgt] if (age_head>70) & (age_head<=75)
gen res=inc/meanpop
gen title="mean income (71-75) / mean income (all)"
save moment10.dta, replace
restore

*mean income (76-80) / mean income (all)  
preserve
egen meanpop = wtmean(inc), weight(wgt)
collapse (mean) inc (mean) meanpop [weight=wgt] if (age_head>75) & (age_head<=80)
gen res=inc/meanpop
gen title="mean income (76-80) / mean income (all)"
save moment11.dta, replace
restore

*mean income (81-85) / mean income (all)  
preserve
egen meanpop = wtmean(inc), weight(wgt)
collapse (mean) inc (mean) meanpop [weight=wgt] if (age_head>80) & (age_head<=85)
gen res=inc/meanpop
gen title="mean income (81-85) / mean income (all)"
save moment12.dta, replace
restore

********
*Panel B
********

preserve
replace wealth=wealth/equiv
gen wtoi=wealth
collapse (mean) wtoi (mean) inc [weight=wgt] if age_head<=30
gen res=wtoi/inc
gen title="Wealth to income (25-30) "
save moment13.dta, replace
restore 

preserve
replace wealth=wealth/equiv
gen wtoi=wealth
collapse (mean) wtoi (mean) inc [weight=wgt] if (age_head>30) & (age_head<=35)
gen res=wtoi/inc
gen title="Wealth to income (31-35) "
save moment14.dta, replace
restore 

preserve
replace wealth=wealth/equiv
gen wtoi=wealth
collapse (mean) wtoi (mean) inc [weight=wgt] if (age_head>35) & (age_head<=40)
gen res=wtoi/inc
gen title="Wealth to income (36-40) "
save moment15.dta, replace
restore 

preserve
replace wealth=wealth/equiv
gen wtoi=wealth
collapse (mean) wtoi (mean) inc [weight=wgt] if (age_head>40) & (age_head<=45)
gen res=wtoi/inc
gen title="Wealth to income (41-45) "
save moment16.dta, replace
restore 

preserve
replace wealth=wealth/equiv
gen wtoi=wealth
collapse (mean) wtoi (mean) inc [weight=wgt] if (age_head>45) & (age_head<=50)
gen res=wtoi/inc
gen title="Wealth to income (46-50) "
save moment17.dta, replace
restore

preserve
replace wealth=wealth/equiv
gen wtoi=wealth
collapse (mean) wtoi (mean) inc [weight=wgt] if (age_head>50) & (age_head<=55)
gen res=wtoi/inc
gen title="Wealth to income (51-55) "
save moment18.dta, replace
restore

preserve
replace wealth=wealth/equiv
gen wtoi=wealth
collapse (mean) wtoi (mean) inc [weight=wgt] if (age_head>55) & (age_head<=60)
gen res=wtoi/inc
gen title="Wealth to income (56-60) "
save moment19.dta, replace
restore

preserve
replace wealth=wealth/equiv
gen wtoi=wealth
collapse (mean) wtoi (mean) inc [weight=wgt] if (age_head>60) & (age_head<=65)
gen res=wtoi/inc
gen title="Wealth to income (61-65) "
save moment20.dta, replace
restore

preserve
replace wealth=wealth/equiv
gen wtoi=wealth
collapse (mean) wtoi (mean) inc [weight=wgt] if (age_head>65) & (age_head<=70)
gen res=wtoi/inc
gen title="Wealth to income (66-70) "
save moment21.dta, replace
restore

preserve
replace wealth=wealth/equiv
gen wtoi=wealth
collapse (mean) wtoi (mean) inc [weight=wgt] if (age_head>70) & (age_head<=75)
gen res=wtoi/inc
gen title="Wealth to income (71-75) "
save moment22.dta, replace
restore

preserve
replace wealth=wealth/equiv
gen wtoi=wealth
collapse (mean) wtoi (mean) inc [weight=wgt] if (age_head>75) & (age_head<=80)
gen res=wtoi/inc
gen title="Wealth to income (76-80) "
save moment23.dta, replace
restore

preserve
replace wealth=wealth/equiv
gen wtoi=wealth
collapse (mean) wtoi (mean) inc [weight=wgt] if (age_head>80) & (age_head<=85)
gen res=wtoi/inc
gen title="Wealth to income (81-85) "
save moment24.dta, replace
restore


********
*Panel C
********

preserve
collapse (mean) h1 (mean) inc [weight=wgt] if age_head<=30
gen res=h1/inc
gen title="Housing value to income (25-30) "
save moment25.dta, replace
restore 

preserve
collapse (mean) h1 (mean) inc [weight=wgt] if (age_head>30) & (age_head<=35)
gen res=h1/inc
gen title="Housing value to income (31-35) "
save moment26.dta, replace
restore 

preserve
collapse (mean) h1 (mean) inc [weight=wgt] if (age_head>35) & (age_head<=40)
gen res=h1/inc
gen title="Housing value to income (36-40) "
save moment27.dta, replace
restore 

preserve
collapse (mean) h1 (mean) inc [weight=wgt] if (age_head>40) & (age_head<=45)
gen res=h1/inc
gen title="Housing value to income (41-45) "
save moment28.dta, replace
restore 

preserve
collapse (mean) h1 (mean) inc [weight=wgt] if (age_head>45) & (age_head<=50)
gen res=h1/inc
gen title="Housing value to income (46-50) "
save moment29.dta, replace
restore

preserve
collapse (mean) h1 (mean) inc [weight=wgt] if (age_head>50) & (age_head<=55)
gen res=h1/inc
gen title="Housing value to income (51-55) "
save moment30.dta, replace
restore

preserve
collapse (mean) h1 (mean) inc [weight=wgt] if (age_head>55) & (age_head<=60)
gen res=h1/inc
gen title="Housing value to income (56-60) "
save moment31.dta, replace
restore

preserve
collapse (mean) h1 (mean) inc [weight=wgt] if (age_head>60) & (age_head<=65)
gen res=h1/inc
gen title="Housing value to income (61-65) "
save moment32.dta, replace
restore

preserve
collapse (mean) h1 (mean) inc [weight=wgt] if (age_head>65) & (age_head<=70)
gen res=h1/inc
gen title="Housing value to income (66-70) "
save moment33.dta, replace
restore

preserve
collapse (mean) h1 (mean) inc [weight=wgt] if (age_head>70) & (age_head<=75)
gen res=h1/inc
gen title="Housing value to income (71-75) "
save moment34.dta, replace
restore

preserve
collapse (mean) h1 (mean) inc [weight=wgt] if (age_head>75) & (age_head<=80)
gen res=h1/inc
gen title="Housing value to income (76-80) "
save moment35.dta, replace
restore

preserve
collapse (mean) h1 (mean) inc [weight=wgt] if (age_head>80) & (age_head<=85)
gen res=h1/inc
gen title="Housing value to income (81-85) "
save moment36.dta, replace
restore

********
*Panel D
********

preserve
gen house_net_wealth=(h1*equiv-m_debt)/equiv
collapse (mean) house_net_wealth (mean) inc [weight=wgt] if age_head<=30
gen res=house_net_wealth/inc
gen title="Housing wealth to income (25-30) "
save moment37.dta, replace
restore 

preserve
gen house_net_wealth=(h1*equiv-m_debt)/equiv
collapse (mean) house_net_wealth (mean) inc [weight=wgt] if (age_head>30) & (age_head<=35)
gen res=house_net_wealth/inc
gen title="Housing wealth to income (31-35) "
save moment38.dta, replace
restore 

preserve
gen house_net_wealth=(h1*equiv-m_debt)/equiv
collapse (mean) house_net_wealth (mean) inc [weight=wgt] if (age_head>35) & (age_head<=40)
gen res=house_net_wealth/inc
gen title="Housing wealth to income (36-40) "
save moment39.dta, replace
restore 

preserve
gen house_net_wealth=(h1*equiv-m_debt)/equiv
collapse (mean) house_net_wealth (mean) inc [weight=wgt] if (age_head>40) & (age_head<=45)
gen res=house_net_wealth/inc
gen title="Housing wealth to income (41-45) "
save moment40.dta, replace
restore 

preserve
gen house_net_wealth=(h1*equiv-m_debt)/equiv
collapse (mean) house_net_wealth (mean) inc [weight=wgt] if (age_head>45) & (age_head<=50)
gen res=house_net_wealth/inc
gen title="Housing wealth to income (46-50) "
save moment41.dta, replace
restore

preserve
gen house_net_wealth=(h1*equiv-m_debt)/equiv
collapse (mean) house_net_wealth (mean) inc [weight=wgt] if (age_head>50) & (age_head<=55)
gen res=house_net_wealth/inc
gen title="Housing wealth to income (51-55) "
save moment42.dta, replace
restore

preserve
gen house_net_wealth=(h1*equiv-m_debt)/equiv
collapse (mean) house_net_wealth (mean) inc [weight=wgt] if (age_head>55) & (age_head<=60)
gen res=house_net_wealth/inc
gen title="Housing wealth to income (56-60) "
save moment43.dta, replace
restore

preserve
gen house_net_wealth=(h1*equiv-m_debt)/equiv
collapse (mean) house_net_wealth (mean) inc [weight=wgt] if (age_head>60) & (age_head<=65)
gen res=house_net_wealth/inc
gen title="Housing wealth to income (61-65) "
save moment44.dta, replace
restore

preserve
gen house_net_wealth=(h1*equiv-m_debt)/equiv
collapse (mean) house_net_wealth (mean) inc [weight=wgt] if (age_head>65) & (age_head<=70)
gen res=house_net_wealth/inc
gen title="Housing wealth to income (66-70) "
save moment45.dta, replace
restore

preserve
gen house_net_wealth=(h1*equiv-m_debt)/equiv
collapse (mean) house_net_wealth (mean) inc [weight=wgt] if (age_head>70) & (age_head<=75)
gen res=house_net_wealth/inc
gen title="Housing wealth to income (71-75) "
save moment46.dta, replace
restore

preserve
gen house_net_wealth=(h1*equiv-m_debt)/equiv
collapse (mean) house_net_wealth (mean) inc [weight=wgt] if (age_head>75) & (age_head<=80)
gen res=house_net_wealth/inc
gen title="Housing wealth to income (76-80) "
save moment47.dta, replace
restore

preserve
gen house_net_wealth=(h1*equiv-m_debt)/equiv
collapse (mean) house_net_wealth (mean) inc [weight=wgt] if (age_head>80) & (age_head<=85)
gen res=house_net_wealth/inc
gen title="Housing wealth to income (81-85) "
save moment48.dta, replace
restore



forval x=1(1)48{
use moment`x'.dta, clear
keep res title
duplicates drop
save moment`x'.dta, replace
}

use moment1.dta, clear
forval x=2(1)48{
append using moment`x'.dta
}

order title res

***
cd ..

outsheet using "`output'/fig3.csv", replace c