1
为什么此代码在Stata中不起作用?它给我的错误是:使用*指定Stata循环中的变量不起作用
* invalid name
然而,当我用,而不是
sexd1 sexd2
sexd*
它工作正常。当我在Stata的命令框中输入命令时,sexd*
可以正常工作。
下面是代码:
local list_of_variables weight midpoint_hhinc
tabulate sex, gen(sexd)
local sexd sexd*
foreach i in `list_of_variables'{
foreach j in `sexd'{
generate `i'_`j' = `i' * `j'
}
}
*被解析为一个穷人的逐项列表
foreach
相当详细的教程 – StasK 2013-02-08 15:12:47