I would appreciate any help that you can give on my question below.
For example, I have the following loop:
foreach var of varlist X1 X2 X3 {
…
reg DV `var' control_set1
reg DV `var' control_set2
…
}
I want to add an IF condition depending on the value of var.
For example, for X2 and X3, add the condition “if fyear>2005”. The effect would be like this:
reg DV X1 control_set1
reg DV X1 control_set2
reg DV X2 control_set1 if fyear>2005
reg DV X2 control_set2 if fyear>2005
reg DV X3 control_set1 if fyear>2005
reg DV X3 control_set2 if fyear>2005
Is it possible to do this in a loop?
Related Posts with IF condition within a loop depending on the iterated value of the loop
help exporting regression/margins results using outreg2 functionHi all, I have been struggling with this for a few days now, would really appreciate any help. I am …
Why weak association and wide confidence intervals?Dear All, I am interested to examine the effect of IPV (Intimate Partner Violence) on my proxy outco…
oaxaca, relax and interpretationDear all, I am using oaxaca to compare two groups in survey data. I include industrie dummies. Beca…
foreach copula command* - Syntax errorDear Stata members i have been trying to make a foreach command to estimate all 6 types of copula m…
Including only time effects in model - how to test specificationHi, Stata users, thank you all for sharing your knowledge and help others! I have panel data, and t…
Subscribe to:
Post Comments (Atom)
0 Response to IF condition within a loop depending on the iterated value of the loop
Post a Comment