Dear All, I have the following survey data set:
Suppose that I have three individuals (ID=1,2,3) and eight waves of surveys (1991,1993,1997,2000,2004,2006,2009, and the last one 2011). But note that some individuals engage in all surveys but others do not. I'd like to form two new variables (ID1 and year1) which consist of all individuals and all waves (years) that are larger than or equal to the first married year `firstmarr'. The desired results are
For ID=1, he participates in all surveys and all survey years are larger than his first married year 1990, so that we keep its ID and all years as the results. For ID=2, while he only participates in four surveys (and his first married year is 1992), I'd like to keep the last seven survey years (1993,1997,2000,2004,2006,2009, and 2011, all are larger than 1992). For ID=3, he only participates in three surveys and his first married year is 2000, A such, I'd like to keep the last five survey years (2000,2004,2006,2009, and 2011, all are larger than or equal to 2000).
Any suggestions?
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(ID year firstmarr final) 1 1991 1990 2011 1 1993 1990 2011 1 1997 1990 2011 1 2000 1990 2011 1 2004 1990 2011 1 2006 1990 2011 1 2009 1990 2011 1 2011 1990 2011 2 1993 1992 2011 2 1997 1992 2011 2 2000 1992 2011 2 2006 1992 2011 3 2000 2000 2011 3 2006 2000 2011 3 2009 2000 2011 end
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(ID_01 year_01) 1 1991 1 1993 1 1997 1 2000 1 2004 1 2006 1 2009 1 2011 2 1993 2 1997 2 2000 2 2004 2 2006 2 2009 2 2011 3 2000 3 2004 3 2006 3 2009 3 2011 end
Any suggestions?
Comment