Hi,
I need to append 60-ish Excel-files with multiple sheets into one .dta-file. I have managed to append them for the first sheet in each Excel-file, however, I do not understand/manage to figure out how I can generate a loop so Stata includes all sheets in each Excel-file. Can anyone help me? Below is the code I have right now:
cd: dir/to/my/folder
local folder: dir "./" files "*.xlsx"
display `folder'
clear
tempfile new_data
/*capture frame drop import*/
frame create import
foreach file in `folder'{
frame import{
import excel "`file'", clear
save "`new_data'", replace
}
append using "`new_data'"
}
Thank in advance!
I need to append 60-ish Excel-files with multiple sheets into one .dta-file. I have managed to append them for the first sheet in each Excel-file, however, I do not understand/manage to figure out how I can generate a loop so Stata includes all sheets in each Excel-file. Can anyone help me? Below is the code I have right now:
cd: dir/to/my/folder
local folder: dir "./" files "*.xlsx"
display `folder'
clear
tempfile new_data
/*capture frame drop import*/
frame create import
foreach file in `folder'{
frame import{
import excel "`file'", clear
save "`new_data'", replace
}
append using "`new_data'"
}
Thank in advance!
Comment