This sounds like ranking to me.
At its very simplest, this could be just
sort var1
gen var2 = _n
but -if- or -in- qualifiers, missing values and tied values could mess
things up.
See help on -egen-'s -rank()- function for a more general tool,
including options for different ranking conventions.
Nick
On Wed, Jan 16, 2013 at 2:28 PM, Rubil Ivica <irubil@eizg.hr> wrote:
> Suppose I have N observations on a variable var1. How to generate
> another variable var2 which takes on values 1 to N, where 1 is assigned
> to the observation with the lowest value of var1, N is assigned to the
> observation with the highest value of var1, and all other values between
> 1 and N are assigned accordingly?
>
> Thanks.
>
>
>
> --
> Ivica Rubil
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/