Hi, I would like to impose a condition in the foreach function on a variable which is not one of the varlist. Is this possible?
foreach var of varlist M_BART_Adj Tu_BART_Adj W_BART_Adj Th_BART_Adj F_BART_Adj Sa_BART_Adj Su_BART_Adj {
if sense>=3{
egen mean_high`var'=mean(`var')
egen se_high`var'=semean(`var')
}
}
The condition is if sense>=3, but Stata does not seem to take this into account.
Related Posts with foreach with if condition
Extension files of OUT.file using X-12 ArimaHi, I am a novice user of Stata and in dire need of help. I am studying the monthly beer sales in bo…
Alternative analyses to xtologit/xtoprobit for score as dependent variable and dummy as independent variableHi everyone, I’m new to Stata (using version 15.1 on Windows 10) and regard my statistical knowledg…
Recoding rules based on string variableHello Statalist, I have a particularly unique, perhaps esoteric question. I am attempting to create…
OveridHello dear analysts I used to use overidentifying test by running the following HTML Code: ivregre…
Alternatives to xtologit/xtoprobit for score as dependent variable and dummy as independent variableHi everyone, I’m new to Stata (using version 15.1 on Windows 10) and regard my statistical knowledge…
Subscribe to:
Post Comments (Atom)
0 Response to foreach with if condition
Post a Comment