I am analysing an unbalanced panel dataset that is similar to the following example:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte(family id) str1 partnerid int(year inc) 1 1 "2" 2000 1250 1 1 "2" 2001 1250 1 1 "2" 2002 1300 1 1 "2" 2003 1300 1 1 "2" 2004 1380 1 1 "2" 2005 1400 1 2 "1" 2000 2000 1 2 "1" 2001 2120 1 2 "1" 2002 2120 1 2 "1" 2003 2120 1 2 "1" 2004 2250 1 2 "1" 2005 2250 2 3 "4" 2000 1300 2 3 "4" 2001 0 2 4 "3" 2000 1500 2 4 "3" 2001 1600 2 4 "." 2002 1600 2 4 "." 2003 1800 2 4 "5" 2004 1800 2 5 "4" 2004 1400 end
The solution should look like this:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte(family id) str1 partnerid int(year inc) str4 partnerinc 1 1 "2" 2000 1250 "2000" 1 1 "2" 2001 1250 "2120" 1 1 "2" 2002 1300 "2120" 1 1 "2" 2003 1300 "2120" 1 1 "2" 2004 1380 "2250" 1 1 "2" 2005 1400 "2250" 1 2 "1" 2000 2000 "1250" 1 2 "1" 2001 2120 "1250" 1 2 "1" 2002 2120 "1300" 1 2 "1" 2003 2120 "1300" 1 2 "1" 2004 2250 "1380" 1 2 "1" 2005 2250 "1400" 2 3 "4" 2000 1300 "1500" 2 3 "4" 2001 0 "1600" 2 4 "3" 2000 1500 "1300" 2 4 "3" 2001 1600 "0" 2 4 "." 2002 1600 "." 2 4 "." 2003 1800 "." 2 4 "5" 2004 1800 "1400" 2 5 "4" 2004 1400 "1800" end
I am using Stata 16.0. on Windows.
Thank you very much for your help in advance.
Best regards,
Marvin
0 Response to How to create a variable from values of other members of a group?
Post a Comment