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

Re: st: Re: Rowsort question

From   Nick Cox <>
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
> 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
> 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
*   For searches and help try:

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