# Re: st: AW: sort by permutation

 From Abdel Rahmen El Lahga To statalist@hsphsun2.harvard.edu Subject Re: st: AW: sort by permutation Date Tue, 22 Dec 2009 12:42:07 +0300

```Thanks martin for the tip and references. Although mechnical your
solution works perfectly.

2009/12/21 Martin Weiss <martin.weiss1@gmx.de>:
>
> <>
>
> BTW, before you get into this exercise, familiarize yourself with the
> hazards of -sort-, as documented in
> http://www.stata-journal.com/sjpdf.html?articlenum=dm0019 and
> http://www.stata.com/support/faqs/lang/sort.html
>
>
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Abdel Rahmen El
> Lahga
> Gesendet: Montag, 21. Dezember 2009 00:34
> An: statalist@hsphsun2.harvard.edu
> Betreff: st: sort by permutation
>
> I have a sample of N individuals belonging to 4 sub-groups g1, g2, g3,
> g4. I would like to sort my sample of size N  in 24 different
> manners, corresponding to all possible permutations of my group
> variable
> say, {g1,g2,g3,g4}, {g1,g3,g2,g4} {g1,g3,g4,g2}...etc.
> Taking a simple exemple for N=10. I have
> id group
> 1    1
> 2    1
> 3    2
> 4    2
> 5    2
> 6    3
> 7    3
> 8    4
> 9    4
> 10  4
>
> one possible sorting among 24 could be
> id group
> 1    1
> 2    1
> 6    3
> 7    3
> 3    2
> 4    2
> 5    2
> 8    4
> 9    4
> 10  4
> any help is apreciated
> --
> AbdelRahmen El Lahga
> *
> *   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/
>

--
AbdelRahmen El Lahga

*
*   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/
```