如何在Stata 14中的全局宏名称中使用本地宏?
例如:
global test1 = 250
local n = 1
. di $test1 // works
250
. di $test`n' // does not work (should be 250 and not 1)
1
18 Programming Stata 手册解释:
“...你可以混合使用全局和本地宏。假设本地宏j包含7.然后,$ {x`j'}扩展为$ x7的内容...”
所以你只需要在全局宏中使用大括号{}
:
. global test1 = 250
. local n = 1
. display $test1
250
. display ${test`n'}
250