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
Parameter constraints for MLE modelDear forum guests! I need to introduce a range constraint for the sum on parameters in MLE model. T…
Frequency table for multiple variablesDear all, As a fairly new user of Stata, I would appreciate any suggestions to create a frequency t…
mlogit - coefficent and marginal effects with different singsHi, I am running a multinational logistic regression with the mlogit command. I have noticed that t…
Looking for alternatives to outreg2Dear Statalist, I am trying to do some descriptives and to export the table to a word document. I u…
Writing paragraphs using putdocx textHi I'm trying to use putdocx to automate a report. When writing long paragraphs, it seems I can't g…
Subscribe to:
Post Comments (Atom)
0 Response to IF condition within a loop depending on the iterated value of the loop
Post a Comment