为什么我不能同时使用foreach循环和carryforward?

huangapple go评论65阅读模式
英文:

Why am I not able to do foreach loop and carryforward together?

问题

当在一个foreach var循环中包含这段代码“bysort countrycode:carryforward 'var', gen(new 'var')”时,Stata会给我一个错误消息。如何解决这个问题?

英文:

When this code "bysort countrycode:carryforward 'var', gen(new 'var')" is included in a foreach var loop, Stata gives me an error message. How to solve this?

答案1

得分: 1

以下是翻译好的部分:

"````
bysort countrycode:carryforward 'var', gen(new 'var')


应该改为

"````
bysort countrycode:carryforward `var`, gen(new`var`)

如果这不是答案,我们需要看到您使用的确切代码以及您收到的错误消息。事实上,该问题未提供最小可重现示例,如https://stackoverflow.com/help/minimal-reproducible-example所述。

英文:

There are two evident errors in the code you cite. The punctuation for referencing a local macro should be different. A new variable name may not include a space.

bysort countrycode:carryforward 'var', gen(new 'var')

should be

bysort countrycode:carryforward `var', gen(new`var')

If this isn't the answer, we need to see the exact code you used and the error message that you got. Indeed, the question falls short of a minimal reproducible example as explained at https://stackoverflow.com/help/minimal-reproducible-example

huangapple
  • 本文由 发表于 2023年2月24日 09:22:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/75551837.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定