How to use SPSS/Compute
The Compute Command[edit | edit source]
The compute command is useful if you want to shift a variable, center, log, square, or adjust the scores in every case in your dataset. The compute command looks like this.
compute (new or current variable name)= (variable name) .
Notice that compute is first followed by a new variable name that does not exist. The compute command can either create a new variable name or adjust a variable depending what you decided to type in to replace (variable name) (without the parenthesis). It is then followed by the "=" and the variable name and whatever mathematical thing you would like to do to it. If you wish to log it, it would look like this: compute educyrs_ln=ln(educyrs+1).
Notice that I placed a new variable name in there rather than just using "educyrs". Also, I used ln to command that I wanted to log a variable and I typed the variable into the parenthesis. Also, I added +1 to shift the cases because you cannot log 0.
To center a variable, find the mean and use the compute command like this:
Compute educyrs_centered=educyrs-(the mean).
Simply just replace your variable names with mine and put in the mean of the variable in the "(the mean)". You might center a variable to put it into a multiple regression so that you can show when you control for your variable that it is or isn't significant.