Hi everyone, I have household panel data, where I have information on everyone living in the household. As such, my data looks somewhat like this:
Here hhid is the household ID; id is the individual identifier; and head is a binary variable indicating whether someone is the head of household (head=1) or not (head=0). In the example above, I present five individuals in two separate households (100 vs 200). In each household, you can see an adult and at least one child. The children enter the panel when they are born (age = 0).
For each child, I would like identify the age of the household head when the child was born. Then, I would like make that variable constant across all waves. Thus, I would like my data to look as follows:
I am quite stumped on how to go about doing this. If anyone knows, I would greatly appreciate the help!
Code:
clear input hhid id year age head 100 1 1990 25 1 100 1 1991 26 1 100 1 1992 27 1 100 1 1993 28 1 100 1 1994 29 1 100 2 1991 0 0 100 2 1992 1 0 100 2 1993 2 0 100 2 1994 3 0 200 3 1981 27 1 200 3 1982 28 1 200 3 1983 29 1 200 3 1984 30 1 200 3 1985 31 1 200 4 1983 0 0 200 4 1984 1 0 200 4 1985 2 0 200 4 1986 3 0 200 4 1987 4 0 200 5 1985 0 0 200 5 1986 1 0 200 5 1987 2 0 200 5 1988 3 0 200 5 1989 4 0 end
For each child, I would like identify the age of the household head when the child was born. Then, I would like make that variable constant across all waves. Thus, I would like my data to look as follows:
Code:
clear input hhid id year age head hage 100 1 1990 25 1 . 100 1 1991 26 1 . 100 1 1992 27 1 . 100 1 1993 28 1 . 100 1 1994 29 1 . 100 2 1991 0 0 25 100 2 1992 1 0 25 100 2 1993 2 0 25 100 2 1994 3 0 25 200 3 1981 27 1 . 200 3 1982 28 1 . 200 3 1983 29 1 . 200 3 1984 30 1 . 200 3 1985 31 1 . 200 4 1983 0 0 29 200 4 1984 1 0 29 200 4 1985 2 0 29 200 4 1986 3 0 29 200 4 1987 4 0 29 200 5 1985 0 0 31 200 5 1986 1 0 31 200 5 1987 2 0 31 200 5 1988 3 0 31 200 5 1989 4 0 31 end
I am quite stumped on how to go about doing this. If anyone knows, I would greatly appreciate the help!
Comment