Hi Stata people,
My several excel files are appended into a single DTA file from various locations. Right now, I'm having trouble figuring out how to add new variables to cells from F3, F4, T3, T4.
Below is the working command that I used, excluding the commands to generate the following division = T[3, the schoolyear = T[4], the schoolid = F[3], and the school = F[4].
clear
set more off
global route "C:\Users\bernie.seville\OneDrive - Palladium International, LLC\Stata command loop test"
cd "$route"
local allfiles : dir "." files "*.xls"
tempfile schroom
clear
save `schroom', emptyok
foreach f of local allfiles {
import excel using "`f'", sheet("school_form_1_ver2014.2.1.1") cellrange(A2) firstrow case(lower) clear
/*
local schoolid= F[3] //not working
gen schoolid=`hname //not working
local school= F[4] //not working
gen school= `school' //not working
local division= T[3] //not working
gen division= `division' //not working
local schoolyear= T[4] //not working
gen schoolyear= `division' //not working
*/
gen source = "`f'"
append using `schroom'
save `schroom', replace
}
Thanks in advance for the help.
My several excel files are appended into a single DTA file from various locations. Right now, I'm having trouble figuring out how to add new variables to cells from F3, F4, T3, T4.
Below is the working command that I used, excluding the commands to generate the following division = T[3, the schoolyear = T[4], the schoolid = F[3], and the school = F[4].
clear
set more off
global route "C:\Users\bernie.seville\OneDrive - Palladium International, LLC\Stata command loop test"
cd "$route"
local allfiles : dir "." files "*.xls"
tempfile schroom
clear
save `schroom', emptyok
foreach f of local allfiles {
import excel using "`f'", sheet("school_form_1_ver2014.2.1.1") cellrange(A2) firstrow case(lower) clear
/*
local schoolid= F[3] //not working
gen schoolid=`hname //not working
local school= F[4] //not working
gen school= `school' //not working
local division= T[3] //not working
gen division= `division' //not working
local schoolyear= T[4] //not working
gen schoolyear= `division' //not working
*/
gen source = "`f'"
append using `schroom'
save `schroom', replace
}
Thanks in advance for the help.
Comment