Hello,

This is my first post - so my apologies in advance if it violates conventions or is unclear. I have looked extensively on StataList and have not found an explanation or solution to this problem.

I have an issue in Stata 16 and how it handles modifying certain values of a continuous variable. The problem could be a "safe-guard" or a glitch. Any insight you could offer would be much appreciated.

I have a sample of several thousand people, and for these individuals, I have a continuous variable varthat I rounded to the nearest 0.1 using -round- which ranges from 0 to 20. I want to produce a histogram of this variable, but work with confidential microdata which requires that I have a minimum number of people in any particular group - and this is only true for certain values of the variable. My immediate solution was to combine a few "low-cell count" groups together. So, for example, if there were only 2 people with a value of 11.1, I would aggregate these people with the group of 50 people that have a value of 11.2.

So, I proceeded to:

Code:
replace var=11.2 if var==11.1
I started realizing that for many of the values I was trying to change, "0 real changes" were being made.

After investigating, I realized that for certain values of the rounded variable var, Stata was adding a 0.0000001 to the number. So for instance, 11.1345 would be rounded to 11.1000001, instead of 11.1. Which is why the above code would not work.

This does not happen with every rounded value, but appears to be random. For example, 6.2157 might be correctly rounded to 6.2, while 3.755 might be incorrectly rounded to 3.8000001. There may also, in some cases, be small subtractions. For example, 4.324 could be 4.2999999. I haven't looked at each and every case. I just know it was common enough that I could not do the above command for all of the values I needed to change.

My questions are:

1. Why would this happen?
2. Is there a solution to this problem? Can I actually get Stata to round to the nearest 0.1 without adding that strange .0000001 to the end of it?

Sorry if this sounds a bit strange, and thanks in advance for your help.