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
stata rdrobust report coefficient covariatesDoes anyone know or know the way to retrieve the coefficients of the covariates in the estimations u…
Using mata functions to define GMM equationsI'd like the use the cumulative distribution function of the multivariate normal as a moment conditi…
how to combine two graphs into one?Hello, I would like to combine the below two graphs into one. The first one shows observed data, and…
How to read the result of anticipation effect assumption test?Regarding Difference-in-Difference, the main assumption is the parallel trend satisfication. Regardi…
Weak identification testHello, I am doing an estimation which involves running a IV regression with 7 endogenous variables …
Subscribe to:
Post Comments (Atom)
0 Response to foreach with if condition
Post a Comment