Hi everyone! I am working with a panel data in which I have both parents and their (adult) children in the Id column. What I would like to do is to match those children with their parents, by using the father and mother identification numbers (variables father and mother). Basically, in my example, I would like to have a line like:
Id (chidlren) year sex birth partner FatherId Fatheryear Fathergender Fbirth Fpartner MotherId .... Mpartner
Where Id (children) are all the Ids for which I have information about both their parents (e.g. father != -5 & mother !=-5).
I think that maybe a loop might work, but I don't know how to approach it.
One major problem is that I don't have the same information for all my IDs: for example ID=1 has 7 years of information, ID=2 5 years and ID=3 6 years.
Is it possible doing something in this case? And if not, if I had the same number of observations for each Id would it be possible?
Thank you very much
Id (chidlren) year sex birth partner FatherId Fatheryear Fathergender Fbirth Fpartner MotherId .... Mpartner
Where Id (children) are all the Ids for which I have information about both their parents (e.g. father != -5 & mother !=-5).
I think that maybe a loop might work, but I don't know how to approach it.
One major problem is that I don't have the same information for all my IDs: for example ID=1 has 7 years of information, ID=2 5 years and ID=3 6 years.
Is it possible doing something in this case? And if not, if I had the same number of observations for each Id would it be possible?
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long(id year) byte gender int birth long(partner father mother) 1 1994 1 1950 2 -5 -5 1 1995 1 1950 2 -5 -5 1 1996 1 1950 2 -5 -5 1 1997 1 1950 2 -5 -5 1 1998 1 1950 2 -5 -5 1 1999 1 1950 2 -5 -5 1 2000 1 1950 2 -5 -5 2 1994 2 1951 1 -5 -5 2 1995 2 1951 1 -5 -5 2 1996 2 1951 1 -5 -5 2 1997 2 1951 1 -5 -5 2 1998 2 1951 1 -5 -5 3 2001 1 1983 -5 1 2 3 2002 1 1983 -5 1 2 3 2003 1 1983 -5 1 2 3 2004 1 1983 -5 1 2 3 2005 1 1983 -5 1 2 3 2006 1 1983 -5 1 2 end
Comment