meglm in foreach loop keeps giving "factor-variable operators not allowed" error however meglm works perfectly outside foreach loop

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

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
}

huangapple
  • 本文由 发表于 2023年7月14日 05:32:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76683368.html
匿名

发表评论

匿名网友

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

确定