>
Kevin,
if I understood clearly what you want to do, the following may do that:
gen Z=minyear
gen Y=maxyear
forvalues x=1/5{
sum lboyear
replace Z=r(min) if regno==`x'
replace Y=r(max) if regno==`x'
}
keep regno lboyear exityear X if lboyear==Z|Zlboyear==Y|lboyear==.
Hope that does what you want.
Dev
>>> [email protected] 12/16/05 11:04 am >>>
Dear all
I've got mysefl stuck on this little problem. My data is in the following form:
regno lboyear exityear X....
1 1992 2003
1 2000 .
1 1992 1996
1 1996 2000
2 2000 2003
2 1993 2000
3 1997 .
3 1993 1997
4 2000 .
5 1999 2002
I would like to:
1. Keep the earliest lboyear and the X variables associated with this earliest lboyear
2. Keep the latest exit year. Note that . indicates no exit, so I would want to keep the dot and not the latest year. I think this is handy as Stata stores it as +infinity.
Any advice is much appreciated.
Kevin
This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/