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

RE: st: RE: Fwd: Neverending loop....


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: Fwd: Neverending loop....
Date   Fri, 13 Dec 2002 12:12:56 -0000

> 
> Here's the code again:
> 
> reshape long own type , i(firm)
> * !!! replace 4 as appropriate by #firms + 1
> bysort firm (own) : gen rank  = 4 - _n
> keep firm own type rank
> reshape wide own type , i(firm) j(rank)
> 

There's a bug here if -own*- is missing. 
Then the sort order is not what you want. 
Here is version #2: 

reshape long own type , i(firm)
replace own = 0 if own == . 
* !!! replace 4 as appropriate by #owners + 1
bysort firm (own) : gen rank  = 4 - _n
keep firm own type rank
reshape wide own type , i(firm) j(rank)

Nick 
n.j.cox@durham.ac.uk 
*
*   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/



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