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

Re: st: Re: Rowsort question


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Re: Rowsort question
Date   Sun, 27 Apr 2003 15:49:11 +0100

Michael Blasnik 

> I think that means just sorting within id by the quantity of
interest.  In
> the example data, assuming there is an id variable, the reshape
approach
> could be:
> 
> reshape long a , i(id) j(obs)
> drop if a==.
> bysort id (a): drop if _n<(_N-2)
> by id : replace obs=_n
> rename a b
> reshape wide b, i(id) j(obs)
> sort id
> save top3
> 
> * this saves a file with id b1 b2 b3 with b3 the largest of a1-a6,
b2 the
> middle, and b1 the smallest, now we put it back into the original
file
> 
> use originaldata
> sort id
> merge id using top3
> 

In addition, some similar examples are discussed 
in some detail at 

I am having problems with the reshape command. Can you give further
guidance?
http://www.stata.com/support/faqs/data/reshape3.html
 
Nick
[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/



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