搜索
人大经济论坛 附件下载

附件下载

所在主题:
文件名:  Stata文件.zip
资料下载链接地址: https://bbs.pinggu.org/a-1836960.html
本附件包括:
  • test.do
  • test.log
  • test_stata11or12_format.dta
  • test_stata14_format.dta
附件大小:
今天处理数据,发现一个诡异的问题:
有一个变量income,float格式,我想建一个新变量group,根据income的大小分成7个组

group income
1 (0-0.1] 小括号代表不包含,中括号代表包含。
2 (0.1-0.5]
3 (0.5-2]
4 (2-5]
5 (5-10]
6 (10-30]
7 (30+]

用如下命令处理,却发现0.1的观测值没有分到group=1里,而是被分到了group=2里,其他组都没有问题。
运行了好几遍都是如此,我用的stata14 for Mac,发现问题以后装stata13试了下,又用stata12 pc版试了下,都是这个问题,真是百思不得其解。请问有人知道原因吗?

附上数据文件、do文件和log日志,各位可以试一下。谢谢!

  1. gen group=.

  2. replace group=1 if income<=0.1
  3. replace group=2 if income>0.1 & income<=0.5
  4. replace group=3 if income>0.5 & income<=2
  5. replace group=4 if income>2 & income<=5
  6. replace group=5 if income>5 & income<=10
  7. replace group=6 if income>10 & income<=30
  8. replace group=7 if income>30

  9. list
复制代码

程序运行日志:

. gen group=.
(102 missing values generated)

.
. replace group=1 if income<=0.1
(0 real changes made)

. replace group=2 if income>0.1 & income<=0.5
(23 real changes made)

. replace group=3 if income>0.5 & income<=2
(31 real changes made)

. replace group=4 if income>2 & income<=5
(16 real changes made)

. replace group=5 if income>5 & income<=10
(9 real changes made)

. replace group=6 if income>10 & income<=30
(15 real changes made)

. replace group=7 if income>30
(8 real changes made)

.
. list

+----------------+
| income group |
|----------------|
1. | .1 2 |
2. | .1 2 |
3. | .1 2 |
4. | .1 2 |
5. | .1 2 |
|----------------|
6. | .1 2 |
7. | .1 2 |
8. | .1 2 |
9. | .1 2 |
10. | .1 2 |
|----------------|
11. | .1 2 |
12. | .1 2 |
13. | .15 2 |
14. | .2 2 |
15. | .2 2 |
|----------------|
16. | .2 2 |
17. | .3 2 |
18. | .3 2 |
19. | .3 2 |
20. | .4 2 |
|----------------|
21. | .5 2 |
22. | .5 2 |
23. | .5 2 |
24. | .6 3 |
25. | .6 3 |
|----------------|






    熟悉论坛请点击新手指南
下载说明
1、论坛支持迅雷和网际快车等p2p多线程软件下载,请在上面选择下载通道单击右健下载即可。
2、论坛会定期自动批量更新下载地址,所以请不要浪费时间盗链论坛资源,盗链地址会很快失效。
3、本站为非盈利性质的学术交流网站,鼓励和保护原创作品,拒绝未经版权人许可的上传行为。本站如接到版权人发出的合格侵权通知,将积极的采取必要措施;同时,本站也将在技术手段和能力范围内,履行版权保护的注意义务。
(如有侵权,欢迎举报)
二维码

扫码加我 拉你入群

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

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

GMT+8, 2026-1-3 21:14