识别包含非整数值的变量中的观察结果

时间:2020-10-12 23:38:07

标签: stata

我正在尝试运行statsby命令,但不断收到group_id: factor variables may not contain noninteger values; an error occurred when statsby executed regress错误。似乎定义组的变量(即“ group_id”)包含非整数值,这会引起麻烦。

我该如何识别非整数案例以便处理它们?还是对此有更全面的方法?

1 个答案:

答案 0 :(得分:2)

* Example generated by -dataex-. To install: ssc install dataex
clear
input float test
  1
  2
3.1
  4
  5
end

tab test if test != round(test, 1)

       test |      Freq.     Percent        Cum.
------------+-----------------------------------
        3.1 |          1      100.00      100.00
------------+-----------------------------------
      Total |          1      100.00

其他类似的解决方案可以使用int()floor()ceil()

相关问题