全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
1014 2
2022-02-25
各位好!
我用stata处理数据时,运用计算生成新变量后,新变量的数值不仅变了,且小数点后面应该有的数也没有了,是怎么回事啊?
数据是这样的:
. dataex qycode goodscode, count(20)
----------------------- copy starting from the next line -----------------------
复制代码

------------------ copy up to and including the previous line ------------------

我用的命令是:
. gen qygoods=qycode+(goodscode/100000000)
. format qygoods %25.8g

以第一行数据为例,运用以上命令后应该是3303936223.85351000,但结果是3303936256。
本以为是因为goodscode和qycode数据类型不一样,但我改了还是不行。
请问大家,问题出在哪里啊?
跪谢啦!
二维码

扫码加我 拉你入群

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

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

全部回复
2023-1-28 22:51:59
你尝试一下在Excel里处理好了再导入Stata软件
二维码

扫码加我 拉你入群

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

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

2023-1-29 16:59:54
Precision of numeric storage types

    floats have about 7 digits of accuracy; the magnitude of the number does not matter.  Thus, 1234567
    can be stored perfectly as a float, as can 1234567e+20.  The number 123456789, however, would be
    rounded to 123456792.  In general, this rounding does not matter.

    If you are storing identification numbers, the rounding could matter.  If the identification
    numbers are integers and take 9 digits or less, store them as longs; otherwise, store them as
    doubles.  doubles have 16 digits of accuracy.


这是帮助里面写的。
double是存储最精确了,但最长只能16位,超过16位就不能精确计算了。
而你的数据整数和小数位数长度超过16了
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群