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
testing the validy of the instrument in xtivregHi, I am using xtivreg , where xtivreg y (x=z) The issue is that how can i tell that the instrume…
how to know whether a placebo test is passedHello! I'm conducting a placebo test on a staggered DID, I randomly assign treatment firms and poli…
Using matching with DID for repeated cross sectional dataI am new to STATA and working on repeated cross-sectional data for Difference-in-Difference analysis…
Example of GMM moment-evaluator program with many equationsHi, Statalist, Does anybody know a simple example of how to implement the moment-evaluator program …
Add on consecutively by groupHi all, I have the first observation for each id for experience, and I would like to replace the v…
Subscribe to:
Post Comments (Atom)
0 Response to IF condition within a loop depending on the iterated value of the loop
Post a Comment