I am running the same code on two different machines and running into an issue with how they represent numbers as local macros. I've written an example that shows the problem:
The reason for the weird conditional (`i' == 12) is because the problem doesn't occur for every number, so I'm just highlighting the case where it does occur.
The issue is as follows: at some point in the code, a variable x is summarized and `r(min)' is saved as a local macro. This leads to some loss of precision, which is fine; however, the way the number changes is not always consistent across machines.
where the first number is the scalar value and the second is the value of the local macro. On the other, the output is
The local is rounded up slightly rather than down.
Both are on Windows and both use Stata 15.1 SE. The machine that produced the first set of results was updated more recently, in February of 2019, while the other was updated in February 2018. Both are on accounts I do not have administrator access to, so I am unable to change that.
Does anyone know what the reason for this could be, and if there's a way to fix it? At this point I'm not sure how feasible it is to replace local macros with scalars, or if it's even possible without changing many of the user-written commands we use.
Code:
clear all cls set type double set seed 4129318 set sortseed 2129318 forval i=1/15 { qui { set obs 500000 gen group = rbinomial(5,0.2) gen x = runiform() sort group x, stable by group: egen x_mean = mean(x) sum x_mean gen m1 = r(min) gen m2 = `r(min)' gen m_diff = m1 - m2 } if `i' == 12 { display %21x m1 display %21x m2 } clear all }
The issue is as follows: at some point in the code, a variable x is summarized and `r(min)' is saved as a local macro. This leads to some loss of precision, which is fine; however, the way the number changes is not always consistent across machines.
Code:
+1.ff58dd3378c69X-002 +1.ff58dd3378c68X-002
Code:
+1.ff58dd3378c69X-002 +1.ff58dd3378c6aX-002
Both are on Windows and both use Stata 15.1 SE. The machine that produced the first set of results was updated more recently, in February of 2019, while the other was updated in February 2018. Both are on accounts I do not have administrator access to, so I am unable to change that.
Does anyone know what the reason for this could be, and if there's a way to fix it? At this point I'm not sure how feasible it is to replace local macros with scalars, or if it's even possible without changing many of the user-written commands we use.