楼主: remix890614
30075 6

[数据管理求助] stata sum命令结果输出的问题 [推广有奖]

  • 2关注
  • 3粉丝

已卖:7份资源

博士生

57%

还不是VIP/贵宾

-

威望
0
论坛币
2965 个
通用积分
0.0006
学术水平
4 点
热心指数
8 点
信用等级
5 点
经验
2902 点
帖子
192
精华
0
在线时间
365 小时
注册时间
2011-12-31
最后登录
2023-2-15

楼主
remix890614 发表于 2011-12-31 14:17:26 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
我在用sum对一列数求和的时候,结果输出的是第一个数到最后一个数的累计求和的数列,我想引用最后的总和,请问怎么改?
二维码

扫码加我 拉你入群

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

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

关键词:Stata 结果输出 tata Sum 最后一个

沙发
蓝色 发表于 2011-12-31 14:35:41

. sysuse auto
(1978 Automobile Data)

. sum price

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       price |        74    6165.257    2949.496       3291      15906

. return list

scalars:
                  r(N) =  74
              r(sum_w) =  74
               r(mean) =  6165.256756756757
                r(Var) =  8699525.974268789
                 r(sd) =  2949.495884768919
                r(min) =  3291
                r(max) =  15906
                r(sum) =  456229


. scalar total=r(sum)

. di total
456229

藤椅
蓝色 发表于 2011-12-31 14:36:38

Title

    [R] summarize -- Summary statistics


Syntax

        summarize [varlist] [if] [in] [weight] [, options]

    options           Description
    ---------------------------------------------------------------------------------------------
    Main
      detail          display additional statistics
      meanonly        suppress the display; calculate only the mean; programmer's option
      format          use variable's display format
      separator(#)    draw separator line after every # variables; default is separator(5)
      display_options control spacing and base and empty cells

    ---------------------------------------------------------------------------------------------
    varlist may contain factor variables; see fvvarlist.
    varlist may contain time-series operators; see tsvarlist.
    by is allowed; see [D] by.
    aweights, fweights, and iweights are allowed.  However, iweights may not be used with the
      detail option; see weight.


Menu

    Statistics > Summaries, tables, and tests > Summary and descriptive statistics > Summary
        statistics


Description

    summarize calculates and displays a variety of univariate summary statistics.  If no varlist
    is specified, summary statistics are calculated for all the variables in the dataset.

    Also see [R] ci for calculating the standard error and confidence intervals of the mean.


Options

        +------+
    ----+ Main +---------------------------------------------------------------------------------

    detail produces additional statistics, including skewness, kurtosis, the four smallest and
        four largest values, and various percentiles.

    meanonly, which is allowed only when detail is not specified, suppresses the display of
        results and calculation of the variance.  Ado-file writers will find this useful for fast
        calls.

    format requests that the summary statistics be displayed using the display formats associated
        with the variables rather than the default g display format; see [D] format.

    separator(#) specifies how often to insert separation lines into the output.  The default is
        separator(5), meaning that a line is drawn after every five variables.  separator(10)
        would draw a line after every 10 variables.  separator(0) suppresses the separation line.

    display_options:  vsquish, noemptycells, baselevels, allbaselevels; see [R] estimation
        options.


Examples

    . sysuse auto
    . summarize
    . summarize mpg weight
    . summarize mpg weight if foreign
    . summarize mpg weight if foreign, detail
    . summarize i.rep78


Saved results

    summarize saves the following in r():

    Scalars   
      r(N)           number of observations
      r(mean)        mean
      r(skewness)    skewness (detail only)
      r(min)         minimum
      r(max)         maximum
      r(sum_w)       sum of the weights
      r(p1)          1st percentile (detail only)
      r(p5)          5th percentile (detail only)
      r(p10)         10th percentile (detail only)
      r(p25)         25th percentile (detail only)
      r(p50)         50th percentile (detail only)
      r(p75)         75th percentile (detail only)
      r(p90)         90th percentile (detail only)
      r(p95)         95th percentile (detail only)
      r(p99)         99th percentile (detail only)
      r(Var)         variance
      r(kurtosis)    kurtosis (detail only)
      r(sum)         sum of variable
      r(sd)          standard deviation

板凳
remix890614 发表于 2011-12-31 14:47:31
蓝色 发表于 2011-12-31 14:35
. sysuse auto
(1978 Automobile Data)
谢谢!但是我有十列数要求和 都这样做有点麻烦啊 用total怎么写命令呢 我是想用求到的和在进行别的运算

报纸
dxystata 发表于 2012-1-1 21:48:38
用循环foreach

地板
yiluo2008 发表于 2012-5-17 09:22:45
不知道,我也有同样困惑

7
区域经济爱好者 发表于 2015-6-7 11:05:42
上面说的都不对。
bysort citycode: egen number= sum( ) 这就是你要的结果。

如果bysort citycode: gen number= sum( ) 这就是你得到的结果。
已有 3 人评分学术水平 热心指数 信用等级 收起 理由
Sunknownay + 3 + 3 + 3 热心帮助其他会员
经管之家APP1998 + 1 + 1 + 1 精彩帖子
学法语去巴黎 + 1 + 1 精彩帖子

总评分: 学术水平 + 5  热心指数 + 5  信用等级 + 4   查看全部评分

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

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