【原创汇总】stata中描述性统计表格的输出

导读:

描述性统计通常对收集来的数据进行直接的频率、频数等描述,描述性统计分析一般对样本的最小值、最大值、平均值、标准偏差等进行分析,这些数据有助于了解样本数据特征,能够清晰的看到各个统计量的分布情况。本文在stata培训会议的基础上,为大家再次呈现一些新的内容,作为补充。

-outreg-

该命令描述为:outreg - reformat and write regression tables to a document file

命令格式为

outreg [using filename] [, options]

将所有变量进行描述分析输出

sysuse auto, clear

(1978 Automobile Data).

outreg2 using daqinxueshu.doc, replace sum(log)

更多技能,指定变量,或者筛选,命令如下:

以下数据来源于计量经济学服务中心stata论文写作专题中盈余管理数据

outreg2 using daqinxueshu.doc, replace sum(log) ///

keep(dacc rid tm size size debt14 eps)

outreg2 using daqinxueshu3.doc, replace sum(log) ///

keep(dacc rid tm size size )

outreg2 using daqinxueshu3.doc, replace sum(log) ///

keep(dacc rid tm size size )  eqkeep(N mean)

outreg2 using daqinxueshu3.doc, replace sum(detail) ///

keep(dacc rid tm size size debt14 eps)

- 描述性分析常用的统计量-

mean,均值

max,最大值

min,最小值

sd,标准差

variance,方差

semean,即sd/√n

skewness,偏度

kurtosis,峰度

p1,第一分位数

p5,第五分位数

p10,第十分位数

p50,中位数

median,中位数

range,max-min

-技能-

这个小技能你get到了吗

global xx 'y x1 x2 x3 x4 x5 x6'

des $xx

tabstat $xx, stat(mean sd min max) columns(s) format(%4.2f)

(XX已经代表了y x1 x2 x3 x4 x5 x6)

tabstat y x1 x2 x3 x4 x5 x6

tabstat y x1 x2 x3 x4 x5 x6,stats(mean p50 min max)

tabstat y x1 x2 x3 x4 x5 x6, stats(mean med min max) col(s) format(%6.2f)

tabstat y x1 x2 x3 x4 x5 x6, s(mean p25 med p75 min max) c(s) f(%6.2f)

tabstat y x1 x2 x3 x4 x5 x6 , s(mean p25 med p75 min max) c(s) f(%6.2f)  by(。)

-logout-

stata外部命令:那些最常用的和最新的命令已经为大家介绍了如何安装一些外部命令,本文为大家介绍命令如下:

ssc install logout

ssc install outreg2

方法1安装外部命令,另外一种方法为:findit logout

程序如下:

sysuse auto.dta,clear

logout, save(logout-basic1) word excel replace: sum price mpg rep78 headroom

输出结果如下:

更完整的统计量,代码如下:

outreg2 using 'logout-basic2', sum(detail) replace word excel dec(3)  keep(price mpg rep78 headroom) eqkeep(N mean sd p5 p25 p50 p75 p95)

tabstat

首先调用stata中的数据,根据统计得到美国汽车产业横截面数据,数据文件名为usaauto.dta。

sysuse auto, clear           // 调用数据,然后do文档,直接快捷键ctrl+D

edit

browse

结果如下:

如果想中途停止该命令的执行,则可以点击Break图标或直接在键盘上同时图标,或直接在键盘上同时按“Ctrl + Break”。运行结果如下。

关于论文、期刊中要求做出来的描述性分析图表,代码如下:

sysuse auto, clear

tabstat price weight length

tabstat price weight length, stats(mean p50 min max)

tabstat price weight length, stats(mean med min max)   col(s) format(%6.2f)

tabstat price weight length, s(mean p25 med p75 min max)  c(s) f(%6.2f)

tabstat price weight length, s(mean sd p25 med p75 min max)  c(s) f(%6.2f) by(foreign)

更多论文格式的分析,代码如下:

Setup

sysuse auto

Show the mean (by default) of price, weight, mpg, and rep78

tabstat price weight mpg rep78

Show the mean (by default) of price, weight, mpg, and rep78 by categories of foreign

tabstat price weight mpg rep78, by(foreign)

In addition to mean, show standard deviation, minimum, and maximum

tabstat price weight mpg rep78, by(foreign) stat(mean sd min max)

Suppress overall statistics

. tabstat price weight mpg rep78, by(foreign) stat(mean sd min max) nototal

Include names of statistics in body of table

. tabstat price weight mpg rep78, by(foreign) stat(mean sd min max) nototal long

Format each variable's statistics using the variable's display format

. tabstat price weight mpg rep78, by(foreign) stat(mean sd min max) nototal long

format

Show statistics horizontally and variables vertically

. tabstat price weight mpg rep78, by(foreign) stat(mean sd min max) nototal long

col(stat)

如何将结果输出到word文档中,代码如下:

sysuse auto, clear

logout, save(mytable) word replace:  tabstat price wei len mpg rep78,  ///

stats(mean sd min p50 max) c(s) f(%6.2f)

直接查看

(0)

相关推荐