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

st: RE: sort on month

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: sort on month
Date   Tue, 8 Sep 2009 14:26:51 +0100

Your -month- is presumably a string variable. For strings, "10" < "2", as string sorts are by dictionary order. 

. d month 

will show you. 

If so, -destring month, replace-. 

A big and common misunderstanding is that changing the -format- changes the way data are held. -format- changes the way data are shown. 

[email protected] 

qing ye

 I was trying to sort the dataset on one variable which indiates
months of the year.
strangly, month 10, 11 and 12 always comes ahead of month 2 and the
other months, anybody know why?

I have formated the variable to be integer, still does not work.

companyan            id                month
Bank of Bolton      20000         1
Bank of Bolton      20000        10
Bank of Bolton      20000        11
Bank of Bolton      20000        12
Bank of Bolton      20000         2
Bank of Bolton      20000         3
Bank of Bolton      20000         4

*   For searches and help try:

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