Statalist


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

st: RE: A query about sorting.


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: A query about sorting.
Date   Tue, 26 Aug 2008 14:32:23 +0100

This generated various suggestions. 

My main thought is that you should never have to write your own sort
programs, bubble sort or other, in Stata. 

Even sorting rows can make use of Stata's own sort functionality -- as
in a combination of -reshape- and -sort-, as mentioned by Maarten Buis
-- or as in -rowsort or -sortrows-, as mentioned in part by Martin
Weiss. 

-rowsort- is on SSC and was written for Stata 8. 

-sortrows- is also on SSC and was written for Stata 9. It makes use of
Mata and in large part supersedes -rowsort-, so long as you have Stata 9
at least. 

Nick 
[email protected] 

Ashim Kapoor

I have a simple code to write.

I have 6 variables v1, v2 , v3, v4 ,v5 , v6.

I want to sort "according to each observation". That is , in the end
for each i I want , v1[i] < = v2[i] <=... v6[i].

So I wrote a simple bubble for each row and then loop from 1 to _N.

Now the problem is that this works but it's VERY VERY slow. Any
comments anyone ?


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