在全局宏的名称中使用本地宏

问题描述 投票: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
global stata local stata-macros
1个回答
1
投票

18 Programming Stata 手册解释:

“...你可以混合使用全局和本地宏。假设本地宏j包含7.然后,$ {x`j'}扩展为$ x7的内容...”

所以你只需要在全局宏中使用大括号{}

. global test1 = 250
. local n = 1

. display $test1
250

. display ${test`n'}
250
© www.soinside.com 2019 - 2024. All rights reserved.