You could create your own tiebreaker variable:
bysort sortvar1 sortvar2 : gen mytiebreaker=_n
Then, whenever you need the same order,you can:
sort sortvar1 sortvar2 mytiebreaker
If you are doing this in an ado file, you could make tiebreaker a temp var.
Michael Blasnik
[email protected]
----- Original Message -----
From: "Dick Campbell" <[email protected]>
To: "statalist-hsphsun2.harvard.edu" <[email protected]>
Sent: Monday, April 05, 2004 6:04 AM
Subject: st: Decsending sort with stable option
> I need to sort a file and preserve the order of tied cases
> within the sort key. I can do this with
> sort x, stable,
> but I need to be in descending order. Gsort
> will do this, but does not have the stable option. Can
> anyone suggest how to do this?
>
> Richard T. Campbell
> Professor of Sociology
> University of Illinois at Chicago
>
> Address and other information at:
> http://www.uic.edu/~dcamp
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/