注意:csv要按utf-8编码
cd "/Users/livy/Desktop/"
filesearch *.xlsx,local(qq)
local qq: subinstr local qq ".xlsx" "", all
foreach i of local qq{
clear
import excel using `i'.xlsx, sheet("sheet1") firstrow
save `i'.dta
}
cd "/Users/livy/Desktop/"
filesearch *.csv,local(qq)
local qq: subinstr local qq ".csv" "", all
foreach i of local qq{
clear
import delimited `i'.csv, case(preserve) encoding(UTF-8)
save `i'.dta
}
cd "/Users/livy/Desktop/"
filesearch *.dta,local(qq)
local qq: subinstr local qq ".dta" "", all
foreach i of local qq{
clear
use `i'.dta, clear
export delimited using `i'.csv, nolabel replace
}