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?
0 Response to IF condition within a loop depending on the iterated value of the loop
Post a Comment