如何过滤整数及其小数点的观察结果?

How to filter observations with whole number and its decimal points?

我有一个包含变量 id 值的数据集,例如 id =[1 2 2.1 3 4 4.1 4.2 5 6 7 7.1 8]。我需要删除有小数点的观察值和小数点前有整数的观察值(例如 2 和 2.1 都将被删除)。这意味着我的预期结果将是 id =[1 3 5 6 8].

* Example generated by -dataex-. For more info, type help dataex
clear
input float id
  1
  2
2.1
  3
  4
4.1
4.2
  5
  6
  7
7.1
  8
end

gen ID = floor(id)

egen bad = total(id != ID), by(ID)

list 

     +----------------+
     |  id   ID   bad |
     |----------------|
  1. |   1    1     0 |
  2. |   2    2     1 |
  3. | 2.1    2     1 |
  4. |   3    3     0 |
  5. |   4    4     2 |
     |----------------|
  6. | 4.1    4     2 |
  7. | 4.2    4     2 |
  8. |   5    5     0 |
  9. |   6    6     0 |
 10. |   7    7     1 |
     |----------------|
 11. | 7.1    7     1 |
 12. |   8    8     0 |
     +----------------+

drop if bad

list id

     +----+
     | id |
     |----|
  1. |  1 |
  2. |  3 |
  3. |  5 |
  4. |  6 |
  5. |  8 |
     +----+