Hello everyone,
I am dealing with a very large panel, the situation is the following,
I want to count the number of households that have a pair of father and son.
The problem is that I have a column for each variable: household id, a column for person id and a column for household label (Father, daughter, son, etc)
Any idea or code you might have?
Here is small example of the issue:
In this case, in HH1 and HH2 there are pairs of father-sons while in HH3 there is not a pair.
The problem I have is that the database is very large (hence, eye inspection is not feasible) and if I try to create a dummy to count the pairs, it is not possible since I don't have any single row with more than one HHrole.
I was thinking on using a code like:
gen pair = (HHrole==1 & HHrole==2)
Where:
(Father=1)
(Son=2)
but this won't work since it requires both conditions to affect the same PERid and this is not the case, since it is for different persons, within the same HHid.
If I could make the code conditional on the same HHid, that might work (in my mind), but I am not sure if that is even possible?, or what would be the code?. Also, where would stata create the dummy? since it needs to consider several rows for the evaluation of the condition, so where would stata create the output?
I hope I have made the issue relatively clear.
Thanks for your kind help,
Best.
I am dealing with a very large panel, the situation is the following,
I want to count the number of households that have a pair of father and son.
The problem is that I have a column for each variable: household id, a column for person id and a column for household label (Father, daughter, son, etc)
Any idea or code you might have?
Here is small example of the issue:
PER id | HH id | HH role |
1 | 1 | Father |
2 | 1 | Son |
3 | 1 | Daughter |
4 | 1 | Mother |
5 | 2 | Father |
6 | 2 | Son |
7 | 2 | Son |
8 | 2 | Nice |
9 | 2 | Mother |
10 | 2 | - |
11 | 3 | Father |
12 | 3 | Mother |
13 | 3 | Grandfather |
14 | 3 | Grandmother |
The problem I have is that the database is very large (hence, eye inspection is not feasible) and if I try to create a dummy to count the pairs, it is not possible since I don't have any single row with more than one HHrole.
I was thinking on using a code like:
gen pair = (HHrole==1 & HHrole==2)
Where:
(Father=1)
(Son=2)
but this won't work since it requires both conditions to affect the same PERid and this is not the case, since it is for different persons, within the same HHid.
If I could make the code conditional on the same HHid, that might work (in my mind), but I am not sure if that is even possible?, or what would be the code?. Also, where would stata create the dummy? since it needs to consider several rows for the evaluation of the condition, so where would stata create the output?
I hope I have made the issue relatively clear.
Thanks for your kind help,
Best.