楼主: shanxinning
48966 13

[数据管理求助] sort之类的命令能否做降序排列 [推广有奖]

  • 0关注
  • 2粉丝

已卖:562份资源

博士生

61%

还不是VIP/贵宾

-

威望
0
论坛币
7217 个
通用积分
0.9150
学术水平
8 点
热心指数
10 点
信用等级
5 点
经验
5285 点
帖子
283
精华
0
在线时间
205 小时
注册时间
2007-11-3
最后登录
2016-5-5

楼主
shanxinning 发表于 2009-4-10 13:34:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

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

二维码

扫码加我 拉你入群

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

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

关键词:降序排列 SOR 有没有 命令 排列 sort

沙发
sungmoo 发表于 2009-4-10 15:20:00

gsort -x

*对x做降序排列

已有 2 人评分经验 学术水平 热心指数 信用等级 收起 理由
Sunknownay + 2 + 2 + 2 热心帮助其他会员
SpencerMeng + 20 热心帮助其他会员

总评分: 经验 + 20  学术水平 + 2  热心指数 + 2  信用等级 + 2   查看全部评分

藤椅
shanxinning 发表于 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

报纸
huper111 发表于 2010-9-14 20:33:12
原来是这样,命令是"proc gsort……;by……;"吗?
从头再来

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

7
windtalker312 发表于 2015-6-6 21:19:46
谢谢沙发君

8
hanlinxian246 发表于 2016-4-19 08:41:33
多谢,学习了!

9
羽亦 发表于 2016-11-20 17:11:41

10
羽亦 发表于 2016-11-20 17:11:43

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-29 07:13