Reputation: 1097
input a
88888888
99999999
end
export excel a.xlsx, replace
Then, if I open the excel file, the numbers are shown as 8.89e+07 and 1.00e+08. How can I restore these to the original numbers. Do I have to do this in Excel? Is there any way to prevent Stata from converting those numbers to the "scientific" format?
Upvotes: 0
Views: 925
Reputation: 37208
The effect of your input
command is to read those numbers into variables of float
type. But there aren't enough bits in a float
to hold 99999999 exactly. This is well documented.
See e.g. the help for data types
:
"float
s 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 long
s;
otherwise, store them as double
s. double
s have 16 digits of accuracy."
So you degraded your data by using an inappropriate data type. That is the issue, not export excel
.
Upvotes: 2