Hi
I have a question regarding the precision of numeric variables imported from excel files. I originally imported about 10 different excel files into Stata 13. (something like import excel "~/stores/coffee. xls", sheet("worksheet1") cellrange(B104:H110) all string clear.
All the excel files had the same variables in the same cell (so cell A11 would be the same variable, i.e., cups of coffee sold on June 24, 2011 for example, etc.) And I sought to make a .dta file that had all the cups of coffee from 10 different vendors sold on June 24, 2011. So, I imported each file and appended, but I noticed that some files imported the same variable as string and other as a numeric variable (byte, float, or double). I chose to import all the variables as strings, then destring them and format them as doubles, and then append them. However, when I did this I noticed I was losing precision with my variables. Specifically, if cell A11 was one variable A12 was another and A13 was the final variable, where in excel A11+A12=A13, I found that in excel if I summed the data from A11 and A12 I got a variable that was every slightly different from A13. If I used the assert command to test whether my sum in state equaled A13 I got messages than in some cases the assertion was false. The difference in variables was small, perhaps 10^-8. But I was wondering why this was happening at all and what I could do to avoid it?
Thank you
Margot
I have a question regarding the precision of numeric variables imported from excel files. I originally imported about 10 different excel files into Stata 13. (something like import excel "~/stores/coffee. xls", sheet("worksheet1") cellrange(B104:H110) all string clear.
All the excel files had the same variables in the same cell (so cell A11 would be the same variable, i.e., cups of coffee sold on June 24, 2011 for example, etc.) And I sought to make a .dta file that had all the cups of coffee from 10 different vendors sold on June 24, 2011. So, I imported each file and appended, but I noticed that some files imported the same variable as string and other as a numeric variable (byte, float, or double). I chose to import all the variables as strings, then destring them and format them as doubles, and then append them. However, when I did this I noticed I was losing precision with my variables. Specifically, if cell A11 was one variable A12 was another and A13 was the final variable, where in excel A11+A12=A13, I found that in excel if I summed the data from A11 and A12 I got a variable that was every slightly different from A13. If I used the assert command to test whether my sum in state equaled A13 I got messages than in some cases the assertion was false. The difference in variables was small, perhaps 10^-8. But I was wondering why this was happening at all and what I could do to avoid it?
Thank you
Margot