文章预览
数据来源:国泰安。 清洗数据 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 ( 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
}
di ".........................................."
save "`fname'.dta" , replace
d
cap g year = 0
ta year , m
} 得到结果 Contains data from iv_equityiv.dta
Observations: 47,219
Variables: 21 29 Jun 2024 20:39
--------------------------------------------------------------------------------------------
Variable
………………………………