全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
48762 13
2009-04-10

一般都用sort做升序排列,有没有做降序排列的命令啊

二维码

扫码加我 拉你入群

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

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

全部回复
2009-4-10 15:20:00

gsort -x

*对x做降序排列

二维码

扫码加我 拉你入群

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

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

2009-4-11 21:36:00
原来如此,我怎么就没想到呢,谢谢谢谢!!
二维码

扫码加我 拉你入群

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

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

2009-4-12 08:52:00
以下是引用shanxinning在2009-4-11 21:36:00的发言:
原来如此,我怎么就没想到呢,谢谢谢谢!!

你如果用stata的帮助的话,在sort命令的解释里面的最下面的链接里面就有介绍gsort

所以要学会知道一个命令以后,如何查找相关的命令


----------------------------------------------------------------------------------------------------------
help for sort                                                                            manual:  [R] sort
                                                                                         dialog:  sort   
----------------------------------------------------------------------------------------------------------

Sort data

        sort varlist [in range] [, stable]


Description

    sort arranges the observations of the current data in ascending order of the values of the variables
    in varlist.  There is no limit to the number of variables in varlist.  Missing values (see help
    missing) are interpreted as being larger than any other number and thus are placed last, with .
    being placed first followed by .a, .b, ... .z.  (Exception:  When sorting on a string variable, null
    strings are placed first.) The dataset is marked as being sorted by varlist unless in range is
    specified.

    Note: ties in the sort index (i.e., identical sorting values) are broken in an arbitrary (i.e.,
    random) order, unless the stable option is specified.


Option

    stable specifies that observations with the same values of the variables in varlist are to keep
        their same relative order in the sorted data as 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  2  |  1  3  |  1  1  |  1  2
                            1  3  |  1  1  |  1  3  |  1  2  |  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 result and never the other five.

        If your intent was to have the observations sorted first on x and then on b within tied values
        of x (the third result above), you should type sort x b and not sort x, stable.

        stable is rarely of use and, when specified, causes sort to execute more slowly.


Examples

    . sort personid
    . sort lstname frstname midinitl

    . regress y x1 x2 x3
    . predict r, resid
    . sort r
    . list in 1/10
    . list in -10/l


Also see

    Manual:  [R] sort

    Online:  help for describe, gsort

二维码

扫码加我 拉你入群

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

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

2010-9-14 20:33:12
原来是这样,命令是"proc gsort……;by……;"吗?
二维码

扫码加我 拉你入群

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

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

2014-10-9 15:55:21
我对收入进行降序排列,用命令gsort -income之后,再list发现收入仍然是按照升序排列的,如何才能降序呢?
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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