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
Issue With Quarterly Data FormatHello Stata community, I am having an issue when trying to create a simple "difference" variable, be…
Requeasting for the exact command to simpson diversifcation index in stataHello, Dear all, I am new for the stata software. Would you please show me the appropriate command t…
dyndoc and css formatingHi all. I run the -dyndoc- command in stata15. I include in my code header and css codes. When I s…
Export SEM models into formatted tablesDear all, Because I have to use FIML in my analyses, I'll have to rewrite my code from using the 'r…
x*x Frequency Table Across A VariableHi Everyone, I am working with a datset that has following variables: 1) mrn: unique identifier 2)…
Subscribe to:
Post Comments (Atom)
0 Response to foreach with if condition
Post a Comment