如何在 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
如何在 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 Sta手册解释说:
“...您可以混合使用全局宏和本地宏。假设本地宏 j 包含 7。那么,${x`j'} 扩展为 $x7 的内容...”
{}
所以你只需要在你的全局宏中使用大括号:
. global test1 = 250
. local n = 1
. display $test1
250
. display ${test`n'}
250