Statalist


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

Re: st: Re: I did it! sorting with a key


From   "Sergiy Radyakin" <[email protected]>
To   [email protected]
Subject   Re: st: Re: I did it! sorting with a key
Date   Fri, 12 Sep 2008 11:50:37 -0400

Hello Shahrul,

No, we want to {swap(a1,a2); swap(b1,b2); ... swap(z1,z2); swap(key1,
key2} if (key2<key1)
E.g. we have observations of mothers, and have fields for their
children. Say Age is a key. We also have other children's
characteristics: gender, birth weight, current weight, survival, etc.
We want to order them by age, and carry the attached characteristics
accordingly. You suggest sorting first by age, then by weight, then by
survival, etc. This will ruin the data, e.g. because a child who is
older is not necessarily heavier.

Regards,
  Sergiy Radyakin


On Fri, Sep 12, 2008 at 11:35 AM, Shahrul Mt-Isa <[email protected]> wrote:
> Hi (Ashim particularly),
>
> This thread seems very interesting and generated a lot of interests. Just
> one comment though: what is your program -keysortrows- trying to achieve?
> From my understanding it does nothing more than running -sortrows- of
> Jeffrey Arnold repeatedly for the variables in question.
>
> For example,
>
> a1      a2      key1    key2
> 2       1       4       2
> 3       4       6       4
> 7       5       8       1
>
> You wanted if key1<key2 then a1<a2.
>
> Then do -sortrows key1 key2- followed by -sortrows a1 a2-
>
> Isn't this what you are trying to achieve?
>
> a1      a2      key1    key2
> 1       2       2       4
> 3       4       4       6
> 5       7       1       8
>
> If it is, I'm sorry to spoil all the fun!
>
>
> BW,
> S Mt-Isa
>
>
> *
> *   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index