首页 > 解决方案 > 识别包含非整数值的变量中的观察值

问题描述

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

如何识别非整数情况以便处理它们?还是有更全面的方法来解决这个问题?

标签: stata

解决方案


* 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().


推荐阅读