wating2003 发表于 2011-1-4 07:12 
谁有比较确定的答案吗? 因为我的数据很多, 抽查了几个好象没什么问题。。。。。。但是如果是不变的话, stable这个功能还要来干嘛??
help和manual中的解释是最有用的
为什么不看看呢
sort.pdf
(115.64 KB)
Option
stable specifies that observations with the same values of the variables in varlist keep the same relative
order in the sorted data that they had previously. For instance, consider the following data:
x b
3 1
1 2
1 1
1 3
2 4
Typing sort x without the stable option produces one of the following 6 orderings.
x b | x b | x b | x b | x b | x b
1 2 | 1 2 | 1 1 | 1 1 | 1 3 | 1 3
1 1 | 1 3 | 1 3 | 1 2 | 1 1 | 1 2
1 3 | 1 1 | 1 2 | 1 3 | 1 2 | 1 1
2 4 | 2 4 | 2 4 | 2 4 | 2 4 | 2 4
3 1 | 3 1 | 3 1 | 3 1 | 3 1 | 3 1
Without the stable option, the ordering of observations with equal values of varlist is randomized.
With sort x, stable, you will always get the first ordering and never the other five.
If your intent is to have the observations sorted first on x and then on b within tied values of x (the
fourth ordering above), you should type sort x b rather than sort x, stable.
stable is seldom used, and, when specified, causes sort to execute more slowly.