英文:
meglm in foreach loop keeps giving "factor-variable operators not allowed" error however meglm works perfectly outside foreach loop
问题
我有一个包含多个二项结果的meglm语句,我试图将它放在一个foreach循环中,但每当我运行这段代码时,它会给我一个错误消息:"不允许因子变量运算符":
foreach variable of varlist burn_post2 {
meglm `variable1' ib0.Active1_Sham0 || Participant:, family(binomial) link(logit) level(95) eform
}
然而,如果我在foreach循环之外运行它,它可以正常运行。
meglm burn_post2 ib0.Active1_Sham0 || Participant:, family(binomial) link(logit) level(95)
可能发生了什么?有没有办法解决这个错误消息?
谢谢!
英文:
I have a meglm statement with multiple binomial outcomes and I am trying to put it in a foreach loop but whenever I run this code, it gives me the error message "factor-variable operators not allowed":
foreach variable of varlist burn_post2 {
meglm `variable1' ib0.Active1_Sham0 || Participant:, family(binomial) link(logit) level(95) eform
}
However if I run this outside the foreach loop, it runs perfectly.
meglm burn_post2 ib0.Active1_Sham0 || Participant:, family(binomial) link(logit) level(95)
What could be going on? Is there anyway to overturn this error message?
Thank you!
答案1
得分: 1
你的代码中有一个拼写错误。你写成了`variable1'
,而应该是`variable'
。
foreach variable of varlist burn_post2 {
meglm `variable' ib0.Active1_Sham0 || Participant:, family(binomial) link(logit) level(95) eform
}
英文:
There is a typo in your code. You wrote `variable1'
where it should be `variable'
.
foreach variable of varlist burn_post2 {
meglm `variable' ib0.Active1_Sham0 || Participant:, family(binomial) link(logit) level(95) eform
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论