How can I write a macro to execute iterative regressions?

I have a group of 10 exposure variables and a group of 10 outcome variables. I would like to write a macro to regress each outcome variable on each exposure variable (a total of 100 regressions) using GEE with logistic regression, but I am unsure of how to code this. Any help would be much appreciated!



New Member
Hi there. :welcome:

Some extra detail would be helpful. Firstly, which statistical package are you using?

Second, some more detail on what you are trying to achieve would be helpful, as there may be a better way of going about things. For example, it may be better to do a multivariate regression with all 10 exposure variables against each outcome variable, so you only have 10 regressions to do.
Last edited:


Less is more. Stay pure. Stay poor.
Macros always seem to trouble me. I saw this macro and thought of your post. This macro runs multiple variables in Proc Logistic then pulls out the AUC values. You may be able to adapt it to do the same thing but pull out your measure of interest, since a hundred regressions take up quite a bit of space. You just need to change the directory and perhaps add multiple dependent variables. I hope this gets you going in the right direction, otherwise I found this macro beneficial all by itself.

'Macro embedded function finds AUC'
Have you worked with macros at all? Here's how I would handle this:

Create two macro variables, one a list of the outcome variables, one a list of the exposure variables. Create a loop that cycles across outcome variables. Within that loop, create a another loop that cycles across exposure variables. Here you would perform logistic regression (why GEE? why not just proc logistic?) and store whatever results you want. Coefficients, p-values, likelihood, etc. You could summarize these all into one dataset (e.g., with columns outcome, exposure, coef, p_val, statistic1 ... statisticn). I do not know if this is the most efficient way to do this, but that is where I would begin if I absolutely had to do it your way.