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
Related Posts with tostring does not return correct values
New versions of xlink and ipwbreg on SSCThanks as always to Kit Baum, new versions of the xlink and ipwbreg packages are now available for d…
Graphing Coefficients From an LPMI'm using the following code to estimate an LPM and the effect of the treatment and interacted varia…
Convert tabs to spaces in results windowHello everyone, I have the habit of inserting tabs in my code to facilitate readability. Apparently,…
I am looking for "Local_Authority_Districts_December_2016_Full_Clipped_Boundaries_in_Great_Britain.zip” file, Can you help?I want to study spatial measurement analysis with stata, but I cann't find the above sample data for…
recursive weighted meanDear All, I find this question here (in Chinese). Suppose the data set is Code: * Example generated…
Subscribe to:
Post Comments (Atom)
0 Response to tostring does not return correct values
Post a Comment