今天在使用stata计算数据时,需要用减法生成一个新的变量,但是发现减法的精度总是出现问题,被减数和减数在计算之前总是自动取整。原始数据如下
stkcd accper asep aset depp dept totp
4 2010/12/31 49700527.51 49542955.17 23182184.400 25176164.36 26518344.000
4 2011/12/31 49543852.85 66100161.71 25177062.040 29480486.25 24366790.000
4 2012/12/31 66100161.71 77230291.10 29480486.250 30706069.09 36619676.000
4 2013/12/31 77230291.10 77074525.20 30706069.090 34531693.45 46524224.000
4 2014/12/31 77074525.20 76444875.26 34531693.450 37164405.97 42542832.000
4 2015/12/31 76444875.26 79241184.36 37164405.970 39999219.61 39280468.000
4 2016/12/31 79241184.36 75557190.18 39999219.610 40632639.25 39241964.000
8 2015/12/31 534122471.30 714514812.10 227096442.600 286443014.60 307026016.000
8 2016/12/31 714514812.10 262907769.90 286443014.600 80076926.28 428071808.000
10 2010/12/31 61135963.13 62302245.22 21068169.780 24607802.41 40067792.000
10 2011/12/31 62302245.22 73734104.13 24607802.410 27431133.28 37694444.000
10 2012/12/31 73734104.13 74553654.11 27431133.280 31518973.94 46302972.000
10 2013/12/31 86065052.43 90524122.38 35281972.690 39653024.67 50783080.000
其中,totp由asep和depp做差取得。
stata代码如下
sort stkcd accper
gen totp=asep-depp
keep stkcd accper totp tott
format totp %19.3f
在我重新将totp与depp相加,验证其是否和asep相等时,返回值为不相等。所以请问各位大神这个应当如何解决?不胜感激


雷达卡



京公网安备 11010802022788号







