<>
As discussed last night between me and Sergiy: You want the whole dataset
with all variables intact plus one that denotes membership in the "club of
most frequent values of mpg"...
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von [email protected]
Gesendet: Dienstag, 17. November 2009 15:28
An: statalist
Betreff: Re: RE: st: AW: Create a flag variable for 10 most frequent values
Suppose we need to flag the 5 most frequent values, how about the following
typings?
sysuse auto, clear
keep mpg
bys mpg: egen mycount=count(mpg)
bys mycount: g num=_n
gsort num -mycount
g tag=_n<=5
bys mycount: egen rank5=max(tag)
Hope it helps!
Rose
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/