Michael didn't mean what he suggested here. The -max()-
function needs two or more arguments and has different syntax
from -egen, max()-.
I think Michael is thinking of code like this:
sort persnr year2
by persnr : gen int maxyear2 = year2[_N]
or, if there are missings, something like
gen maxyear2 = cond(missing(year2), 0, year2)
sort persnr maxyear2
by persnr : replace maxyear2 = maxyear2[_N]
will mean one fewer variable.
Nick
[email protected]
Michael Blasnik
sort persnr year2
by persnr: gen int maxyear2=max(year2)
gen byte touse=year2<,
sort persnr touse year2
by persnr touse: gen int maxyear2=max(year2) if touse
drop touse
by persnr (maxyear2): replace maxyear2=maxyear2[1]
*
* 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/