clear
cd C:\Users\Administrator\Desktop\8月份对账
*1. 将文件夹下所有excel文件变成dta格式
xls2dta,replace recursive : import excel using 8月各村社银行日记账
* 2.对文件夹下所有dta文件进行同样操作
clear
local w:dir . files "*.dta"
foreach j in `w'{
use "`j'",clear
drop in 1
drop in -2/-1
gen k = A
replace k = substr(A,16,30)
replace k= k[_n-1] if k==""
drop in 1/3
save "`j'",replace
}
* 3.对处理的单个dta文件进行合并
clear
local w:dir . files "*.dta"
foreach j in `w'{
append using "`j'"
}
* 4.导出为excel表格
export excel using "C:\Users\Administrator\Desktop\8月份对账\8月银行日记账表.xls"