Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: why -odbc- made error?


From   "Joseph Coveney" <jcoveney@bigplanet.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: why -odbc- made error?
Date   Sat, 1 Aug 2009 00:51:22 +0900

Rose wrote:

Thank you very much for your reply!
Now that sometimes errors indeed exist,
I will consider other methods instead of openning EXCEl directly in the stata.

--------------------------------------------------------------------------------

Before trying tedious or complicated other methods, consider a couple of
experiments to see if they fix the problem.

First:

By default, ODBC scans only the first eight rows in order to guess the datatype
(numeric or text).  Your variable c was empty for the first eight rows, and ODBC
might have assumed that the blank cells would be text.

Try specifying the rows to scan in the DSN string as follows to see whether it
works for your dataset:

odbc load, table(1998$) dsn("Excel Files;DBQ=xxx.xls;MaxScanRows=16;")

Second:

If that doesn't work, then try the workaround--it's not very complicated,
actually only two lines of code:

odbc load, dsn("Excel Files;DBQ=xxx.xls;") ///
  exec("SELECT * FROM [Excel 8.0;HDR=YES;IMEX=1;Database=xxx.xls;].[1998$];")
destring x-c, replace

Joseph Coveney


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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