Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Ordering a dataset by frequency

From   "Nick Cox" <>
To   <>
Subject   st: RE: Ordering a dataset by frequency
Date   Mon, 5 Mar 2007 17:47:39 -0000

bysort name : gen negfreq = -_N 
sort negfreq name 

> 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.  Thus far I have used bigtab to tabulate the 
> results, but I 
> don't know how to order such a large dataset by freq. , since 
> many commands 
> are refused due to having "too many variables".  The names 
> are listed as 
> string variables.  I used encode name, gen(firstname) to create a new 
> variable with numerical value, but when I use the sort 
> command it sorts it 
> into alphabetical order.  Do you have any idea how I order 
> the data by frequency? 

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index