[email protected] wrote,
> I have a dataset of 50,000 names. I need to order them by frequency so
> that the names that recur the most are at the top of the list, decreasing
> by frequency. [...]
If I just wanted to list the names and frequencies, in effect making a
one-way tabulation, I would type
. use dataset
. keep name
. sort name
. by name: gen freq = _N
. by name: keep if _n==1
. gsort -freq name
. list name freq
If I wanted to save the frequencies with the original data:
. use dataset
. sort name
. by name: gen freq=_N
. save, replace
If I wanted to list the entire dataset with the most frequent names on top,
. gen negfreq = -freq
. sort negfreq name
-- Bill
[email protected]
*
* 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/