Hello everyone,
I’m encountering a problem when importing numeric variables (and/or converting from strings) into Stata, and I can’t figure out what causes it.
The data values I’m working with have this format:
205000000.00
When I import everithing as a string the values are correct, but....
The issue is that when I import as numeric or convert from string to numeric, strange things happen:
I’m encountering a problem when importing numeric variables (and/or converting from strings) into Stata, and I can’t figure out what causes it.
The data values I’m working with have this format:
205000000.00
Code:
I have tried several import syntaxes, for example: import delimited "NAMEFILE.csv", bindquote(strict) delimiter(";") varnames(1) encoding("utf-8") clear or import delimited "NAMEFILE.csv", bindquote(strict) stringcols(_all) delimiter(";") varnames(1) encoding("utf-8") clear destring varibles list, replace
The issue is that when I import as numeric or convert from string to numeric, strange things happen:
- Sometimes decimal places are lost (and ther is write . 00 )
- Sometimes decimals remain intact
- Sometimes numbers get rounded automatically
- But the strangest part is that sometimes the last digits of the non-decimal part of the number change unpredictably, producing results that are close but not exactly equal to the true value, with discrepancies usually smaller than around 100.
Comment