[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: RE: RE: RE: RE: RE: Strings and the greater than/less than operators |

Date |
Thu, 14 May 2009 15:34:30 +0100 |

It seems so. Stata sorts strings as a dictionary would, except for the order of its alphabet. If you want to sort strings on their numeric content, create a sort key variable with just that numeric content. In simple cases, -destring- will suffice, but with attention to its options. Nick n.j.cox@durham.ac.uk sdm1 I was thinking about sorting strings in the same way as one would sort numerics so that, for example, a four digit integer is always greater than a three digit integer. Clearly I shouldn't think like this when it comes to strings because "N12 " is less than "N13" and, although 1234 is greater than 124, "1234" is less than "124". When thinking about the sort order of strings, would it be sensible to think of them being left aligned (whereas with integers they're right aligned)? * * 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/

**Follow-Ups**:**st: RE: RE: RE: RE: RE: RE: RE: Strings and the greater than/less than operators***From:*"sdm1" <sdm1@york.ac.uk>

**References**:**st: Strings and the greater than/less than operators***From:*"sdm1" <sdm1@york.ac.uk>

**st: RE: Strings and the greater than/less than operators***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**st: RE: RE: Strings and the greater than/less than operators***From:*"sdm1" <sdm1@york.ac.uk>

**st: RE: RE: RE: Strings and the greater than/less than operators***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**st: RE: RE: RE: RE: Strings and the greater than/less than operators***From:*"sdm1" <sdm1@york.ac.uk>

**st: RE: RE: RE: RE: RE: Strings and the greater than/less than operators***From:*"sdm1" <sdm1@york.ac.uk>

- Prev by Date:
**st: RE: RE: RE: RE: RE: Strings and the greater than/less than operators** - Next by Date:
**st: RE: RE: RE: RE: RE: RE: RE: Strings and the greater than/less than operators** - Previous by thread:
**st: RE: RE: RE: RE: RE: Strings and the greater than/less than operators** - Next by thread:
**st: RE: RE: RE: RE: RE: RE: RE: Strings and the greater than/less than operators** - Index(es):

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