Stata 使用tabout命令时结果不一致
我想使用社区贡献的命令Stata 使用tabout命令时结果不一致,stata,Stata,我想使用社区贡献的命令tabout生成一个汇总表 但是,在一个简单的交叉表中,输出是不一致的 下面的代码是我尝试执行的一个有限示例: tab demaut revyn if demaut<.5 | Revolution (Y/N) Polity | NO YES | Total -----------+----------------------+---------- 0 | 341
tabout
生成一个汇总表
但是,在一个简单的交叉表中,输出是不一致的
下面的代码是我尝试执行的一个有限示例:
tab demaut revyn if demaut<.5
| Revolution (Y/N)
Polity | NO YES | Total
-----------+----------------------+----------
0 | 341 13 | 354
.05 | 682 91 | 773
.1 | 309 55 | 364
.15 | 1,171 259 | 1,430
.2 | 409 96 | 505
.25 | 149 80 | 229
.3 | 191 32 | 223
.35 | 268 82 | 350
.4 | 172 23 | 195
.45 | 165 75 | 240
-----------+----------------------+----------
Total | 3,857 806 | 4,663
The total observations are 4,663.
demat=.05、.1、.15…
的所有观察值均缺失,但总观察值是正确的
有什么建议吗?以下内容适合我:
sysuse auto, clear
tab mpg foreign if mpg < 20
Mileage | Car type
(mpg) | Domestic Foreign | Total
-----------+----------------------+----------
12 | 2 0 | 2
14 | 5 1 | 6
15 | 2 0 | 2
16 | 4 0 | 4
17 | 2 2 | 4
18 | 7 2 | 9
19 | 8 0 | 8
-----------+----------------------+----------
Total | 30 5 | 35
tabout mpg foreign using temp.tex if mpg < 20, replace c(count mpg) format(0c) sum
Table output written to: temp.tex
Car type
Mileage (mpg) Domestic Foreign Total
Count mpg Count mpg Count mpg
12 2 0 2
14 5 1 6
15 2 0 2
16 4 0 4
17 2 2 4
18 7 2 9
19 8 0 8
Total 30 5 35
sysuse自动,清除
tab如果mpg<20,则mpg为外部
里程|车型
(mpg)|国内外|总计
-----------+----------------------+----------
12 | 2 0 | 2
14 | 5 1 | 6
15 | 2 0 | 2
16 | 4 0 | 4
17 | 2 2 | 4
18 | 7 2 | 9
19 | 8 0 | 8
-----------+----------------------+----------
总数| 30 5 | 35
使用temp.tex标记mpg外部如果mpg<20,则替换c(计数mpg)格式(0c)和
表输出写入:temp.tex
车型
里程(mpg)国内外合计
计数mpg计数mpg计数mpg计数mpg
12 2 0 2
14 5 1 6
15 2 0 2
16 4 0 4
17 2 2 4
18 7 2 9
19 8 0 8
总数30 5 35
此外:
禁止使用temp.tex输入mpg。如果mpg<20,则替换c(N mpg平均mpg)和1
表输出写入:temp.tex
是的
mpg
英里数(mpg)
12 2.0 12.0
14 6.0 14.0
15 2.0 15.0
16 4.0 16.0
17 4.0 17.0
18 9.0 18.0
19 8.0 19.0
总数35.0 16.7
车型
国内30.016.7
国外5.0 16.8
总数35.0 16.7
Polity N Mean
revyn revyn
0 354.0 0.0
.05 0.0
.1 0.0
.15 0.0
.2 0.0
.25 229.0 0.3
.3 0.0
.35 350.0 0.2
.4 195.0 0.1
.45 0.0
Total 4,663.0 0.2
sysuse auto, clear
tab mpg foreign if mpg < 20
Mileage | Car type
(mpg) | Domestic Foreign | Total
-----------+----------------------+----------
12 | 2 0 | 2
14 | 5 1 | 6
15 | 2 0 | 2
16 | 4 0 | 4
17 | 2 2 | 4
18 | 7 2 | 9
19 | 8 0 | 8
-----------+----------------------+----------
Total | 30 5 | 35
tabout mpg foreign using temp.tex if mpg < 20, replace c(count mpg) format(0c) sum
Table output written to: temp.tex
Car type
Mileage (mpg) Domestic Foreign Total
Count mpg Count mpg Count mpg
12 2 0 2
14 5 1 6
15 2 0 2
16 4 0 4
17 2 2 4
18 7 2 9
19 8 0 8
Total 30 5 35
tabout mpg foreign using temp.tex if mpg < 20, replace c(N mpg mean mpg) sum one
Table output written to: temp.tex
N Mean
mpg mpg
Mileage (mpg)
12 2.0 12.0
14 6.0 14.0
15 2.0 15.0
16 4.0 16.0
17 4.0 17.0
18 9.0 18.0
19 8.0 19.0
Total 35.0 16.7
Car type
Domestic 30.0 16.7
Foreign 5.0 16.8
Total 35.0 16.7