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]
st: Import multiple excel sheets
From
Michael Betz <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: Import multiple excel sheets
Date
Fri, 7 Sep 2012 15:40:07 +0000
Hi all,
I need to import many excel files that each have multiple worksheets and then append them. I have about 51 files that vary in the number of sheets each one has. They are named 'file1' file2' 'file3'...ect. Each sheet is named 'Unit' Unit1' 'Unit2'...ect (Note the first sheet doesn't have a number in its name). I've been thinking about the problem in the following manner, but got stuck because I'm not sure how to import the multiple sheets from each file when each file has a different number of sheets.
forvalues i=1/51{
import excel "C:\Users\file`i'.xls", sheet("Unit") firstrow case(lower) clear
if `i'>1 append using "mainfile"
save "mainfile", replace
}
Any thoughts?
Thanks,
Mike
*
* 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/