Dear Stata Community,
while exporting some data to csv I experienced a problem that also appears when rounding variables. I wouldn't wonder if the problem has been posted before and apologize in advance if it is the case.
The problem appears when rounding a fairly large variable and then either exporting it into a csv file or e.g. calculating a mean and saving it in string variable.
An example code provoking the error is:
A similar problem appears when I try to export the data to csv. Interestingly, it does not work with the example above but with a larger dataset. Here is a sample of the resulting csv file( All numeric variables were in double before exporting and looked fine):
ID;value;;;;
1;64.40000000000001;;;;
2;278.83;;;;
3;15.22;;;;
4;173.51;;;;
5;90.10000000000001;;;;
6;206.93;;;;
7;6.41;;;;
8;65.48999999999999;;;;
9;124.02;;;;
10;94.23999999999999;;;;
11;68.94;;;;
12;12.11;;;;
Does anyone know what causes the error and perhaps a solution?
Best,
Dave
while exporting some data to csv I experienced a problem that also appears when rounding variables. I wouldn't wonder if the problem has been posted before and apologize in advance if it is the case.
The problem appears when rounding a fairly large variable and then either exporting it into a csv file or e.g. calculating a mean and saving it in string variable.
An example code provoking the error is:
Code:
clear all set obs 1 gen double x = 6615151515.120 gen double x_r = round(x,.2) sum x_r if _n == 1 gen hv = "`r(mean)'"
ID;value;;;;
1;64.40000000000001;;;;
2;278.83;;;;
3;15.22;;;;
4;173.51;;;;
5;90.10000000000001;;;;
6;206.93;;;;
7;6.41;;;;
8;65.48999999999999;;;;
9;124.02;;;;
10;94.23999999999999;;;;
11;68.94;;;;
12;12.11;;;;
Does anyone know what causes the error and perhaps a solution?
Best,
Dave
Comment