Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: sorting rows with a "key"


From   "Sergiy Radyakin" <serjradyakin@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: sorting rows with a "key"
Date   Wed, 10 Sep 2008 12:52:46 -0400

Hello Ashim,

see the earlier reply of Nick Cox in the thread:
http://www.stata.com/statalist/archive/2008-08/msg01169.html

In particular this paragraph:
------- quote NJC --------------
3. -rowsort- and -sortrows- are not intended for this problem in which
Sergiy has

motherid   child_id1 child_id2 child_id3 age1 age2 age3 gender1 gender2
gender3
.....
and might want to sort children by age keeping their ordering stable
and moving their (string) ids and (numeric) gender dummies in sync.

They are indeed useless at that problem. But see -rowranks- from SSC.
That's not intended, quite, for that problem either, but it is perfectly
soluble using basic Stata.
------- end quote NJC --------------

Best regards, Sergiy Radyakin



On Wed, Sep 10, 2008 at 2:01 AM, Ashim Kapoor <ashimkapoor@gmail.com> wrote:
> Hello everyone,
>
> I have a small question. I really liked the program "sortrows" . I
> wish to ask if anyone has written a similar program for sorting with a
> "key".
>
> I mean the following.:=
>
> say I have 4 variables ( in my case I have around a 100 so I cannot
> possibly do it in the usual manual bubble sort because it takes
> forever)
>
> say a1 a2 key1 key2
>
> I want to say sortrows ( key1 key2)  which will do the usual sortrows
> BUT it will also sort the a1 and a2 in the same order ie. if k1 < k2
> then a1 < a2 for that row.
>
> Any tips ? Any program which already does this ?
>
> Thank you,
> Ashim.
> *
> *   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/
>
*
*   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   |   What's new   |   Site index