I have some panel data that is somewhat messy in capturing individuals' education, because of a combination of relatively high missingness in the education variable as well as the fact that respondents are fairly different ages at the onset of the survey.
What I want to do, then, is just simply create a variable that is the max value of -educ- (years of education) by the time the respondent is age 21. I've tried a few combinations of bysort (): gen max but have run into trouble because 21 is not the max age of anyone in the survey. Here's some basic data:
What I want to do, then, is just simply create a variable that is the max value of -educ- (years of education) by the time the respondent is age 21. I've tried a few combinations of bysort (): gen max but have run into trouble because 21 is not the max age of anyone in the survey. Here's some basic data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte id int year byte(age educ) 1 1990 16 10 1 1991 17 . 1 1992 18 12 1 1993 19 12 1 1994 20 . 1 1995 21 . 1 1996 22 13 1 1997 23 14 1 1998 24 15 2 1990 20 . 2 1991 21 14 2 1992 22 14 2 1993 23 14 2 1994 24 14 2 1995 25 14 2 1996 26 . 2 1997 27 . 2 1998 28 . end
Comment