Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: sort within values


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: sort within values
Date   Wed, 26 Sep 2012 09:36:46 +0100

. sort var1
. gen var2 = var1[1]

???

Nick

On Wed, Sep 26, 2012 at 9:19 AM, Michele Santacatterina
<[email protected]> wrote:

> i was wondering how to sort a numeric variable within the values. Here an example, var1 contains 2 values (12,21) i would like to sort within var1 in order to create var2 = (12,12)
>
> var1 var2
> 12      12
> 12      12
> 12      12
> 12      12
> 21      12
> 21      12
> 21      12
> 21      12
>
> furthermore i have the same question for a string variable, for example if i have var1 (A+E , E+A) i would like to create a var2 (A+E,A+E).
>
> var1    var2
> A+E             A+E
> A+E             A+E
> E+A             A+E
> E+A             A+E
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index