-
Notifications
You must be signed in to change notification settings - Fork 0
/
ind_321sample.do
112 lines (62 loc) · 1.67 KB
/
ind_321sample.do
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
use "data\workdata\malmorelationerextended.dta", clear
keep lopnrgems* generation *by
drop if by==.
drop by
tempfile all
save `all'
* Create 321 panel indicator file
* Restrict gen2
use `all', clear
keep if generation=="Indexgen"
drop generation
drop if fatherby==. & motherby==.
drop lopnrgemsmor lopnrgemsfar
duplicates drop
merge 1:1 lopnrgems using "data\workdata\estimation_data_2ndGen.dta", nogenerate keep(match)
keep if w2!=. & w1!=.
keep lopnrgems
tempfile gen2
save `gen2'
use `all', clear
keep if generation=="Barn"
drop generation
duplicates drop
rename lopnrgems lopnrgems3
* Keep only those with wealth observations
merge 1:1 lopnrgems3 using "data\workdata\estimation_data_3rdGen.dta", nogenerate keep(match)
drop if w3==.
rename lopnrgems3 lopnrgems
drop *3
keep lopnrgems*
tempfile gen3
save `gen3'
use `gen2', clear
rename lopnrgems lopnrgemsmor
merge 1:m lopnrgemsmor using `gen3', keepusing(lopnrgems) keep(match) nogenerate
rename lopnrgems lopnrgemsbarn
rename lopnrgemsmor lopnrgems
tempfile gen3m
save `gen3m'
use `gen2', clear
rename lopnrgems lopnrgemsfar
merge 1:m lopnrgemsfar using `gen3', keepusing(lopnrgems) keep(match) nogenerate
rename lopnrgems lopnrgemsbarn
rename lopnrgemsfar lopnrgems
tempfile gen3f
save `gen3f'
append using `gen3m'
duplicates drop
tempfile g32
save `g32'
keep lopnrgems
duplicates drop
save "data\workdata\gen2ind_321sample.dta", replace
use `g32', clear
bysort lopnrgems: egen count=count(lopnrgemsbarn)
keep lopnrgemsbarn count
rename lopnrgemsbarn lopnrgems3
duplicates drop
bysort lopnrgems3: egen childcount=mean(count)
drop count
duplicates drop
save "data\workdata\gen3ind_321sample.dta", replace