Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Question about tabsort (shorter alternative)


From   "Nick Cox" <[email protected]>
To   <[email protected]>, <[email protected]>
Subject   st: RE: Question about tabsort (shorter alternative)
Date   Fri, 12 Jul 2002 17:43:16 +0100

I just replied to Rodrigo Briceno 

< snip > 

> His code is similar, if I'm understanding properly:  
> 
> bysort clave1 : gen freq = _N 
> egen tag = tag(clave1) 
> gsort - tag - freq 
> gen order = _n 
> tabdisp order in 1/10 if tag, c(clave1 freq) 
> 

That's all using official Stata. 

Here's an alternative solution, using the 
-egen- function -egroup()- downloadable from 
-egenmore-, and discussed yesterday on Statalist. 
Note the minus sign in the first command. 

bysort clave1 : gen freq = - _N 
egen group = egroup(freq clave1) , l(clave1) 
tabulate group if group < 11 

<<attachment: winmail.dat>>




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