Dear Statalisters,
I've imported a large .txt file to Stata using import delimited. The file has a few numeric variables, which are very long (18 digits) so Stata display them as e+ (e.g. 1.23e+17). I wanted these values to display in full so converted them to string, using
tostring(var), gen(newvar) format ("%20.0f")
However, some of the values returned inaccurate. So for instance, the correct value I expected (i.e. what is in the original .txt file) should have been 123456, but in Stata the it becomes 123457. It seems that after being converted they were rounded up somehow. What confuses me is that there's no decimal places, so it shouldn't be rounded up or down.
Could anyone shed any light on what might have happened and how do I fix this issue (i.e. to convert the numeric variables to string but keep the values the same as what they were in the original .txt file)?
Many thanks
0 Response to tostring does not return correct values
Post a Comment