今天看啥  ›  专栏  ›  Stata与R学习

Stata学习:CSMAR美股基金持股数据库!

Stata与R学习  · 知乎专栏  ·  · 2024-04-28 21:14
清洗数据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{ foreach v of var * { la var `v' "`=`v'[1]'" replace `v' = "" if _n == 1 } drop in 1/2 cap g year = substr(ReportDate,1,4) cap order year 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 *ta year,m } u uss_fundholdshares, clear ap using uss_fundholdshares1 uss_fundholdshares2 so SecurityID ReportDate sa uss_fundholdshares_2023, replace d ta y,m 变量预览Contains data from uss_fundholdshares_2023.dta Observations: 2,414,531 Variables: 13 28 Apr 2024 21:13 ------------------------------------------------------------------------------------------------ Variable Storage Display Value name ty ………………………………

原文地址:访问原文地址
快照地址: 访问文章快照