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
Compare percentage across different tablesHey I want to compare percentages across tables. So, for example I want to test if investor_A inve…
Generating a new variable as a result of comparing the mean of a variable (t-test) in two different timesHi, I have three variables here in my example, as described below. 1) EXP: is the time dummy variab…
cox regression with shared frailty or vce clusterHello, In running a cox regression model (stcox), I would like to look at within group correlation.…
Coefficient interpretation in log-level regression- Actual impact of independent variable on dependent variable.Hi all, I have a regression where the dependent variable is in log form. I was wondering if we can …
alternative to interaction term in regressionHi all, I am examining the interaction effect between X and Y (outcome var is Z) using fixed effect…
Subscribe to:
Post Comments (Atom)
0 Response to foreach with if condition
Post a Comment