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" <>
To   <>
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

----- Original Message ----- 
From: "Dick Campbell" <>
To: "" <>
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:

*   For searches and help try:

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