Tips & Tricks #30 – macro programming of regression
I got a question from a experienced SPSS user some weeks ago, and I couldn’t answer it – both myself and the user googled and searched for how to use a macro to repeat the regression model with one x-variable from a couple of variables against a y variable. So 50 x-variables should end with 50 regression models.
The user finally found the answer and sent it to me, so now I will share it with you.
Here is the data file (example):
I want to make 4 regressions, y1 against x1, y1 against x2, y1 against x3 and finally y1 against x4.
To make this macro I used this example from the SPSS user, it’s a syntax file:
I have marked with different colors to clarify a little how it works. (I have then also tried this macro as a basic macro for other analysis like ANOVA, t-test and so on).
To run the macro: mark the syntax text and click the green triangle in the tool bar (“run current”).
Then I get 4 regressions made, repeated. Here I have just hidden the other regression tables (to save some space in this blog post) so you can see the 4 coefficient regression result repeated:
Thanks for watching!
Gunilla