今天处理数据,发现一个诡异的问题:
有一个变量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日志,各位可以试一下。谢谢!
程序运行日志:
. 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 |
     |----------------|
 Stata文件.zip
大小:(2.43 KB)
Stata文件.zip
大小:(2.43 KB)
 马上下载
本附件包括:
- test.do
- test.log
- test_stata11or12_format.dta
- test_stata14_format.dta