Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: ODBC getting Excel vartype wrong


From   kturner@stata.com (Kevin Turner)
To   statalist@hsphsun2.harvard.edu
Subject   st: Re: ODBC getting Excel vartype wrong
Date   Tue, 25 Oct 2005 15:50:35 -0500

Thomas J. Steichen (steicht@rjrt.com) writes:

>I ran into a second ODBC problem. I have a column in Excel whose cells
>are formatted as text but is being read by ODBC as number. Most of
>the cells in the column are of the form 1234567.8 (which is why the 
>error occurs) but some are of form 1234567.t9, and these are set to
>missing when transferred to Stata.  Recovering this information in
>Stata, once the value is set to missing, is impossible, so the
>question is, how to force ODBC to honor the text format in Excel?

Try the -allstring- option. You can convert to numeric, if needed, once you get
the data into Stata.

Usually, if the format is set properly on the first/second cell of the column
in question, the Excel ODBC driver will use that format for the rest of the
column. However, type issues are not uncommon when dealing with Excel since
there is no concept of a variable and every cell can have a unique type.
Microsoft simply developed an Excel ODBC driver that imports data if it meets
certain format assumptions.

--Kevin Turner
kturner@stata.com
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index