Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: import excel-file too big
From
Subrata Bhattacharyya <[email protected]>
To
[email protected]
Subject
Re: st: import excel-file too big
Date
Mon, 22 Aug 2011 23:18:02 +0530
local xlsfile "dho_daily_30000_2011-07-30(1).xls"
Hi Ricardo,
You have create the ODBC connection first before you can call data
from it. Either you create them manually or create them on the fly:
// declare name of the Excel file to read from
local xlsfile "dho_daily_30000_2011-07-30(1).xls"
// list the worksheets of interest
local sheets ""Sheet1" "Sheet2" "Sheet3" "Sheet4""
// Extract data from Excel to Stata
local sheetno: list sizeof sheets
forvalues i=1/`sheetno' {
local k: word `i' of `sheets'
local my_sheet "`k'"
local source "Excel Files;DBQ=`xlsfile'"
clear
odbc load, dsn("`source'") table("`my_sheet'$")
Regards,
Subrata
On Mon, Aug 22, 2011 at 8:06 PM, Ricardo Ovaldia <[email protected]> wrote:
>
> Thank you Subrata.
>
> However, I can not get the -odbc- to work in Stata 12. I get the following error:
>
> . odbc load, dsn("test_file.xlsx") table("sheet1") clear
> The ODBC driver reported the following diagnostics
> [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
> SQLSTATE=IM002
> r(682);
>
> The file is in the working directory:
>
> . dir test_file.*
> 45.0M 8/22/11 9:29 test_file.xlsx
>
>
> What am I doing wrong?
>
> Ricardo.
>
>
>
> Ricardo Ovaldia, MS
> Statistician
> Oklahoma City, OK
>
>
> ----- Original Message -----
> From: Subrata Bhattacharyya <[email protected]>
> To: [email protected]
> Cc:
> Sent: Monday, August 22, 2011 8:34 AM
> Subject: Re: st: import excel-file too big
>
> Hi Ricardo,
>
> You might want to try -odbc-.
>
> Regards,
> Subrata
>
> On Mon, Aug 22, 2011 at 7:00 PM, Ricardo Ovaldia <[email protected]> wrote:
>>
>>
>> Hello,
>>
>> I wrote an -do- file that first imports a series of excel sheets into Stata using the -import- command.
>> However, some of the sheets are too big and I get the corresponding error message "File too big".
>> I can convert the sheet to a tab delimited txt file and use -insheet- to import. That works, but this is tedious because I have lots of files and they will change from time to time.
>> Is there a way (code) to create the tab delimited txt file from inside the -do- program? Or does anyone have an alternative that can be automated?
>>
>> Thank you,
>> Ricardo
>>
>> Ricardo Ovaldia, MS
>> Statistician
>> Oklahoma City, OK
>>
>>
>> *
>> * 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/
>
> *
> * 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/
>
>
> *
> * 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/
>
*
* 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/