ARCHIVED: In SPSS, how do I run multiple sets of regressions without having to retype the command each time?

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

SPSS has a macro facility designed to customize functions from existing commands, allowing you to run a series of commands using different variables in each iteration.

For example, if you want to run a series of regressions using different dependent variables but the same independent variables, you can use the SPSS macro facility to create a list of your dependent variables. After defining your macro, you can direct its output to a single regression command, which will then proceed through each of the dependent variables you listed in the macro.

The following example contains three dependent variables (y1-y3) and three independent variables (x1-x3). The commands establish a macro that will run three regressions using each of the dependent variables against all of the independent variables:

  DEFINE M ()
    y1 y2 y3.
  !ENDDEFINE.

  REGRESSION VAR = M x1 x2 x3
   /DEP = M /METHOD = ENTER.

The line DEFINE M () tells SPSS the name of the function to define. In this example, the macro is called M. The next line lists the variables that M is equal to, and consists of the dependent variable names on a line indented at least one space. Finally, the line !ENDDEFINE. specifies the end of the macro.

The second group of commands shows how this macro is used. Instead of typing the dependent variable names in the regression command, use the macro name (M, in this example). This single command will then execute for each value of M, thus producing three different regression analyses with one command.

If you have questions about using statistical and mathematical software at Indiana University, contact the UITS Research Applications and Deep Learning team.

This is document afii in the Knowledge Base.
Last modified on 2023-05-09 14:37:08.