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

Stata学习:CSMAR数字经济数据库!

Stata与R学习  · 知乎专栏  ·  · 2024-03-08 15:29
清洗数据cd C:\Download\1 fs *.zip foreach f in `r(files)'{ unzipfile `f' } * fs *.xlsx foreach f in `r(files)'{ import excel using "`f'" , firstrow clear qui{ labone, n(1) drop in 1/2 cap g year = substr(EndDate,1,4) qui foreach v of var * { cap destring `v', replace } cap ren SgnYear year cap ren Symbol Stkcd cap order year cap order Stkcd sca f_temp = "`f'" loc fname = usubinstr(f_temp,".xlsx","",.) compress } di ".........................................." save "`fname'.dta", replace d ta y }得到结果仅整理部分结果:Contains data from dm_areahigtecprotmy.dta Observations: 639 Variables: 19 8 Mar 2024 15:28 ------------------------------------------------------------------------------------ Variable Storage Display Value name type format label Variable label ------------------------------------------------------------------------------------ year int %10.0g ………………………………

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