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
Augmented dickey fuller test on residuals?Hello, I am writing my bachelor thesis trying to measure the effect of cryptocurrency 'forks' (fork …
Structural VAR with Orthogonalised Impulse Response FunctionsHi, This might be a really basic question for some of you but I have been looking up how to interpr…
heckman sample selection and VIFHi, I am using heckman in stata for below specification, I want to check multicollinearity and VIF,…
Is it necessary to declare data set as panel data?Hi, if my data are panel-data (observations are unique by city and year), is it necessary to declar…
Performing PCA by groupDear all, I an trying to perform a PCA analysis by company on panel data. The goal is to create an…
Subscribe to:
Post Comments (Atom)
0 Response to IF condition within a loop depending on the iterated value of the loop
Post a Comment