# Loop over a variable prefix in SPSS for regression [closed]

I want to loop over a variable index to generate a regression model for each predictor. This is not possible with either loop or do repeat.

I have a set of predictors like var1_indep, var2_indep, var3_indep.and I would like to produce three regressions; one for each of the predictors.

loop # = 1 to 2.
regress /dependent my_dep_var /method=enter var_#_indep.
end loop.


However, the loop command is not valid for regression. Anyone knows if there is an alternative? Thanks in advance.

• As the correct answer goes, you should use macro facility or (another option) python programmability. Loop command operates only on transformations of data cases, it cannot do cycling of procedures. Aug 6 '20 at 21:28
• To loop over prefixes in a macro, use !concat function within !do !v !in() cycle Aug 6 '20 at 21:30

define regs()