Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: sort within values


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
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
<miksanta@hotmail.it> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index