STATA 读取PYTHON计算结果
// sfi.Macro提供对Stata宏的访问。 // // 参数 内容 getGlobal(Name) 获取全局宏的内容 getLocal(Name) 获取局部宏的内容 setGlobal(name, value[, vtype]) 设置全局宏的值 setLocal(name, value) 设置局部宏的值 python from sfi import Data from sfi import Datetime from sfi import Frame from sfi import Macro from sfi import ValueLabel cca="北京" ac=cca.split(' ') for ii in ac: Macro.setLocal('x',ii) end disp "`x'" local jieguo "" use cgss\cgss2015,clear local k=_N ds,has(type string) local bbb="`r(varlist)'" local cc "" foreach var of varlist `bbb'{ gen ab=0 replace ab=ab+1 if strrpos(`var',"`x'") & (!missing(`var')) sum ab if `r(sum)'>0{ local cc="`cc'"+" "+"`var'" disp "`cc'" //continue,break } drop ab } disp "`cc'"