文章预览
数据来源:国泰安。 清洗数据 cd C : \ Download \ 1
fs *. zip
foreach f in ` r ( files ) '{
unzipfile ` f '
}
*
fs *. xlsx
foreach f in ` r ( files ) '{
import excel using "`f'" , first clear
qui {
labone , n ( 1 )
drop in 1 / 2
cap ren Symbol Stkcd
cap g year = substr ( Accper , 1 , 4 )
cap g year = substr ( EndDate , 1 , 4 )
cap order year
cap order Stkcd
qui foreach v of var * {
cap destring ` v ', replace
}
sca f_temp = "`f'"
loc fname = usubinstr ( f_temp , ".xlsx" , "" , . )
compress
save "`fname'.dta" , replace
}
di ".........................................."
d
cap g year = 0
ta year
} 得到结果 先更新部分: Contains data from fl_leaseliabstat.dta
Observations: 46,973
Variables: 11 3 Jul 2024 20:32
-----------------------------------
………………………………