That is not provided by -egen, mode()-, but
a first principles approach gets you there:
Assume identifier -id- and time -time-.
We want the mode of -myvar-, breaking
ties for the highest frequency by
which occurs latest.
bysort id myvar : gen freq = _N
replace freq = 0 if missing(myvar)
bysort id (freq time) : gen mode = myvar[_N]
Nick
[email protected]
David Kantor
> At 04:53 PM 5/22/2007, Nick Cox wrote:
> >[...]
> >
> >I don't think there is any obvious way to handle ties
> >for mode. There might be substantive solution(s) to that.
>
> -egen ... mode()...-
> has some options for handling ties. In case anyone is interested, I
> wrote a variation that breaks ties by taking the
> latest-occurring in the data.
*
* 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/