描述
summarize命令计算并显示各种单变量摘要统计信息。如果未指定varlist,则计算数据集中所有变量的摘要统计信息。
语法
summarize [varlist] [if] [in] [weight] [, options]
主要语法解释
1.varlist:需要统计的变量。
2.if :样本条件。
3.in:样本范围。
4.weight:样本权重。
options选项解释
1.detail:显示其他统计信息,包括偏度,峰度,四个最小值和四个最大值以及各种百分位数。
2.meanonly:抑制显示; 只计算平均值; 程序员的选择。仅在未指定细节时才允许,禁止显示结果和计算方差。
3.format:使用变量的显示格式。格式请求使用与变量关联的显示格式而不是默认g显示来显示摘要统计信息。
4.separator(#) :在每个#变量之后绘制分隔线,指定将分隔线插入输出的频率。 默认值为separator(5),这意味着每五个变量后画一条线。separator(10)会在每10个变量后画一条线。separator(0)抑制分离线。
5.display_option:控制间距,线宽,基本和空单元格。
例子
. sysuse auto
. summarize
. summarize mpg weight
. summarize mpg weight if foreign
. summarize mpg weight if foreign, detail
. summarize i.rep78
Stored results
summarize stores 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