# SPSS Tutorials

BASICS REGRESSION T-TEST ANOVA CORRELATION

# Mean Centering Variables in SPSS

“I'd like to mean center a lot of variables in order to compute interaction terms for a regression analysis. Is there an easy way to do this for many variables simultaneously?”

## Mean Centering - What and Why

• This tutorial focuses on mean centering variables in SPSS. However, we'll briefly introduce the concept first.
• Mean centering a variable means subtracting its (arithmetic) mean from all its values.
• The result is that a mean centered variable has a mean of exactly zero. (Apart from that, its frequency distribution does not change.)
• Note that mean centering is also one of the two steps in standardizing variables (computing their z-scores).
• Mean centering without fully standardizing variables is usually done before computing interaction terms in regression analysis.
• Doing so decreases multicollinearity between an interaction term and its corresponding main effects. It may also facilitate the interpretation of regression coefficients for the interaction terms.

## SPSS Mean Center Tool

SPSS Mean Center Variables Tool
• Make sure you have the SPSS Python Essentials installed.
• Download and install Mean Center Variables. Note this is an SPSS custom dialog.
• Go to Utilities Mean Center Variables. Fill in the names of the variables you’d like to mean center.
• By entering a prefix, mean centered variables will be created as new variables in the active dataset. With the prefix left empty, the original variables will be overwritten by their mean centered counterparts.
• Click and run the pasted syntax.
• As a quick check, you could run `DESCRIPTIVES` on the mean centered variables to confirm that they all have zero means.
• Clicking the tool's button will take you to this tutorial. We very much appreciate your feedback on it.

# Let me know what you think!

*Required field. Your comment will show up after approval from a moderator.

# This tutorial has 37 comments

• ### By Yunyi on August 21st, 2015

Hello,
I use spss21. The output shows error message like: >Error # 6890. Command name: begin program
>Configuration file spssdxcfg.ini is invalid.
>Execution of this command stops.
Configration file spssdxcfg.ini is invalid because the LIB_NAME is NULL.

I didn't save the "mean center variables" custom dialog at the same place of the SPSS. Could that be the reason that lead to it doesn't work?

• ### By Ruben Geert van den Berg on August 20th, 2015

"I am running SPSS 22 which should have the Python installed automatically" No, that's not entirely correct. During SPSS' installation process, you need to select a tick box for installing the Python Essentials as well. If you don't do so, you'll have SPSS 22 without the Python Essentials.

I think uninstalling and reinstalling SPSS altogether from scratch -and making sure the Python Essentials are selected- may be the only way to get things up and running but I can't say for sure. Another visitor recently had similar problems and posted them here. To my surprise, however, it seems he didn't receive help yet -at least not publicly.

I'll contact him personally to see whether perhaps he got instructions in a private message. If that doesn't help, I'll contact somebody from SPSS support myself. I've seen this issue too many times and I can perhaps better support my visitors by writing a tutorial on resolving this problem.

• ### By Ema on August 19th, 2015

Hi, I am running into the same problem as described by Stephanie below and getting the following erro: Error # 6890. Command name: begin program
Configuration file spssdxcfg.ini is invalid.
Execution of this command stops.
Configration file spssdxcfg.ini is invalid because the LIB_NAME is NULL.

I am running SPSS 22 which should have the Python installed automatically, how do I hence uninstall it as you suggested to her? Many thanks!

• ### By Ruben Geert van den Berg on July 4th, 2015

The simplest option is adjusting the variable specification: note that you can use TO here and your data having a mixture of numeric and string variables is the exact reason we wrote it like we did. For instance, if you have n1 n2 n3 s1 n4 in your data where "n" denotes "numeric" and "s" denotes "string", `n1 to n3 n4` will specify the numeric variables only.

Alternatively, you could move all string variables to the end of your file by a tiny Python script.

HTH,

Ruben

• ### By Emily on June 30th, 2015

Hi, I I have run the macro without problem for a few select variables and now would like to perform it on all variables in a dataset by typing ALL in the variable list in the utility box. I keep getting an error stating that the aggregate command cannot run because there are string variables in the dataset.

>Error # 10938. Command name: aggregate
>A function which requires a numeric variable has been used with a string
>variable.

How can I get the syntax to skip over string variables or ignore them altogether? Thanks.

Emily
(I run SPSS 22.)