Dear All,

I have a couple of problems with macro and loops (they migh be correlated anyway):

First:

suppose I have the following models:

Code:
reg y x z
reg y x z k
reg y x z k w
Regressors have completely different names. I would like to set a loop to run those regressions. I tried the following:

Code:
global set1 "x z"
global set2 "x z k"
global set3 "x z k w"

local All "set1 set2 set3"

foreach s in local All{
reg y `s'
est store mod_`s'
}


It happens that Stata run many models one for each variable within the global macro, instead of having only 3 estimations.

Second:

Another problem is the following. I have many models and usually I need to drop some variables. For instance i use "x z k w a b c d e f g" as regressors. In some cases I need to drop regressor "a", in other cases regressor "e" and so on. Is there any way I can do it within a loop? Maybe exploiting the position of each variable within the string?

As I mentioned above, the two problems may be correlated each other. Possibily, solving the second one could solve the first as well.


Thanks in advance.

Dario