Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73275

Precision of Numeric Variables Imported From Excel (.xls)

$
0
0
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

Viewing all articles
Browse latest Browse all 73275

Trending Articles


FLASHBACK WITH SIRASA FM AT GALGAMUWA 2022


Mp3 Download: Mdu - Mazola


Imitation gun was fired at motorist in Leicester road-rage incident


Ndebele names


MCKINNEY EMALINE “EMMA” OF WES...


Okra & Motia — The Workshop (Prod by Hammer)


Skint TV teen to be sentenced


Moondru Mudichu 19-09-2017 – Polimer tv Serial


YOSVANI JAMES Arrested by Miami-Dade County Corrections on Jan 10, 2017


Stories • Goddess Stepmom



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>