Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte id str2 stratum float(exp sex) byte(ISCEDlevel EDUCATTAIN) float(HF10year t HF10age chISCED chptISCED ISCEDchange) 6 "19" 0 2 1 1 1997 1 17.67 . . 6 6 "19" 0 2 1 . 1998 2 18.67 0 0 6 6 "19" 0 2 1 . 1999 3 19.67 0 0 6 6 "19" 0 2 2 . 2000 4 20.67 1 1 6 6 "19" 0 2 2 . 2001 5 21.67 0 0 6 6 "19" 0 2 2 . 2002 6 22.67 0 0 6 6 "19" 0 2 5 . 2003 7 23.67 3 1 6 6 "19" 0 2 5 . 2004 8 24.67 0 0 6 6 "19" 0 2 5 . 2005 9 25.67 0 0 6 6 "19" 0 2 7 7 2006 10 26.67 2 1 6 6 "19" 0 2 7 . 2007 11 27.67 0 0 6 6 "19" 0 2 7 . 2008 12 28.67 0 0 6 6 "19" 0 2 7 . 2009 13 29.67 0 0 6 6 "19" 0 2 7 . 2010 14 30.67 0 0 6 6 "19" 0 2 7 . 2011 15 31.67 0 0 6 6 "19" 0 2 7 . 2012 16 32.67 0 0 6 6 "19" 0 2 7 . 2013 17 33.67 0 0 6 6 "19" 0 2 7 . 2014 18 34.67 0 0 6 7 "99" 1 2 1 1 1995 1 16.5 . . 4 7 "99" 1 2 1 . 1996 2 17.5 0 0 4 7 "99" 1 2 1 . 1997 3 18.5 0 0 4 7 "99" 1 2 1 . 1998 4 19.5 0 0 4 7 "99" 1 2 2 . 1999 5 20.5 1 1 4 7 "99" 1 2 2 . 2000 6 21.5 0 0 4 7 "99" 1 2 2 . 2001 7 22.5 0 0 4 7 "99" 1 2 2 . 2002 8 23.5 0 0 4 7 "99" 1 2 2 . 2003 9 24.5 0 0 4 7 "99" 1 2 2 . 2004 10 25.5 0 0 4 7 "99" 1 2 2 . 2005 11 26.5 0 0 4 7 "99" 1 2 5 5 2007 12 28.5 3 1 4 7 "99" 1 2 5 . 2008 13 29.5 0 0 4 7 "99" 1 2 5 . 2009 14 30.5 0 0 4 7 "99" 1 2 5 . 2010 15 31.5 0 0 4 7 "99" 1 2 5 . 2011 16 32.5 0 0 4 7 "99" 1 2 5 . 2012 17 33.5 0 0 4 7 "99" 1 2 5 . 2013 18 34.5 0 0 4 7 "99" 1 2 5 . 2014 19 35.5 0 0 4 17 "45" 0 2 1 1 2009 1 14.21 . . 0 17 "45" 0 2 1 . 2010 2 15.21 0 0 0 17 "45" 0 2 1 . 2011 3 16.21 0 0 0 17 "45" 0 2 1 . 2012 4 17.21 0 0 0 17 "45" 0 2 1 . 2013 5 18.21 0 0 0 17 "45" 0 2 1 . 2014 6 19.21 0 0 0 end
The dataex above is a fictive sample from a large ( N 100 000+) observational epidemiological study using record linkage.My primary interest is educational attainment , i.e. highest completed level of education. In the dataex.dta the variable of interest is named EDUCATTAIN. I have got it almost right, but the persons who have not any education after O-levels (9/10th grade) gives me problems.
The command
replace EDUCATTAIN = 1 if ISCEDlevel[_N]==1 & t ==1 yielded the actual dataex.dta
All three persons have EDUCATTAIN ==1 at t[1], not only those with ISCEDlevel ==1 at [_N]
Where is my thinking wrong?
Happy New Year
Søren Nielsen
Comment