谢谢分享!但是我碰到了一个问题,不知是否有朋友可以为我解答~就是我根据数据修改了这个代码,跑出来总是显示
foreach command may not result from a macro expansion in
> teractively or in do files
r(198);
我的代码如下:
use `"D:\中国工业企业数据库-相关\original_1998.dta"',clear
. global vars "region_code zip telephone cic founding_year founding_month"
. qui foreach v of varlist $vars{
. gen x=`v'
. destring x ,replace force
. gen n=.
. forv i=1/`=r(width)'{
. replace n=indexnot(x,"0123456789")
. replace x=substr(x,1,n-1)+substr(x,n+1,.)
. }
. gen z=real(x)
. drop x n
. rename z `v'1
. }
|