全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
3575 6
2011-01-02
想问一下 ,如果有很多变量 eg: a, b, c,d,e, f, g, h ......, 当用sort的时候,是否以一行行的观测值来重排的?
也就是说当我用
sort a b
这个指令会导致其余变量(c d e f g h)的混乱吗?
还是一定要用
sort a b, stable?
手册上说stable不常用,因为会让运行速度变慢很多

好像我解释得有点混乱呢 。。。。大概意思就是想知道sort a b后, a1,a2,a3 原先对应的其他变量是否仍在同一行?

谢谢
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2011-1-2 10:31:39
可以查一下。。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-1-4 07:12:31
谁有比较确定的答案吗? 因为我的数据很多, 抽查了几个好象没什么问题。。。。。。但是如果是不变的话, stable这个功能还要来干嘛??
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-1-4 07:28:06
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.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-1-4 10:38:15
4# 蓝色


先谢谢版主的解答 :)
我之前看过的, 我明白例子说的, 只是不是很确定在变量多过2的时候,比如变量: a, b, c,d,e, f, g, h ......,
当我用sort a b 时,在相同的a b值里,其余变量(c d e f g h) 是以一行行的方式随机排列吗(randomized by row rather than randomized within each individual variable)?

PS 我测试过了, 不用stable不会导致数据混乱,所以stable很少需要用到, 只会拖慢速度。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-10-5 11:41:11
wating2003 发表于 2011-1-4 10:38
4# 蓝色
我用stata10,sort一个数据之后其余的数据就凌乱了,所以stable还是有用的@@
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群