Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: Decsending sort with stable option


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: Decsending sort with stable option
Date   Mon, 5 Apr 2004 07:20:34 -0400

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
michael.blasnik@verizon.net


----- Original Message ----- 
From: "Dick Campbell" <dcamp@uic.edu>
To: "statalist-hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index