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
Interpretation of terms in discontinuous growth model – mixed commandHello everyone, I am estimating a discontinuous growth curve model for a study about the impact of …
Nbreg with i.id for fixed effects not convergingHi, I have a panel dataset consisting of 3,617 IDs where each ID has about 9-10 observations for it…
declare survey design for datasetHello, I have a question regarding how to correctly declare survey design for a dataset I am analyz…
How to find upward variable bias?Dear Statalisters, I am currently running some analysis on a few different dependent variables in a…
Difference-in-difference with three time periodsDear all, I am working on my bachelor essay and I have to use stata for a regression. My topic is t…
Subscribe to:
Post Comments (Atom)
0 Response to foreach with if condition
Post a Comment