Dear Statalisters,
There have been several parallel threads on using local macros to create lists of variables when running repetitive regressions, for instance changing the outcome variable but keeping the same model variables (or vice-versa). I found these useful in learning about the foreach command.

I would like to be able to use local to create a block of variables and then loop over these blocks so that the first model would be a minimally adjusted (containing two or three variables) and then a fully adjusted model containing all the variables I wish to control for.

At the moment I have developed the following command strategy:

local predictors "x1 x2 x3 x4 x5 x6 x7"
local outcome "y1 y2"
foreach x of local predictors {
local regressors `regressors' `x'
foreach y of local outcome {
local model `y' `regressors' `x'
reg `y' `regressors'
}
}

What this does is run consecutive regressions for outcome y1 first adding in x1 to the model, then y2 adding in x1 to the model. In the next round, y1 is the outcome and then x1 and x2 are included in the model, then y2 as the outcome with x1 and x2 in the model and so forth.

Order of operations:
reg y1 x1
reg y2 x1
reg y1 x1 x2
reg y2 x1 x2
reg y1 x1 x2 x3
reg y2 x1 x2 x3 .....

My question is - can a local be defined such that I can save variables x1 x2 x3 as the 'minimally' adjusted model [i.e as block1] and then in the next round of the loop x4 x5 x6 x7 are all added in at the same time for the 'fully' adjusted model [i.e. block1 + block2].

In other words, I would like the order of operations to be:
reg y1 x1 x2 x3
reg y2 x1 x2 x3
reg y1 x1 x2 x3 x4 x5 x6 x7
reg y2 x1 x2 x3 x4 x5 x6 x7

I am using Stata v14.2

Many thanks,
Alexander