英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论