## Search This Blog

Compute
The Compute procedure allows the analyst to perform mathematical operations on variables. This can be useful for several reasons. You might want to transform a variable to make its distribution more normal, or to make its relationship to another variable more linear. You also might want to create a variable that represents the average of other variables in the data set. You should use Compute whenever you want to assign the value of one variable to be a mathematical function of other variables in the data set.

To perform this type of a transformation

. Choose Transform then Goto Compute.
. Type the name of the new variable in the target variable box. If you .  type in the name of a variable that already exists, the transformed values will replace the existing values.
. Type the formula representing what the value of the target variable should be in the numeric expression box.
. Click the OK button.

The screen that opens up when you choose the Compute procedure has three different parts. On the left side of the screen there is a list of the variables in your data set. If you double-click on a variable it will be added to the computation formula listed in the numeric expression box. You do not have to use this if you do not want to - you can  lways just type in the names of the variables in your formula by hand.
In the center of the screen is what appears to be a calculator keypad. This allows you to add specific arithmetic functions to your formula. The keypad contains the following buttons for mathematical computations.
- (subtraction)
* (multiplication)
/ (division)
** (raising something to a power)

The calculator keypad also contains the followings functions that allow you to compare variables and values. These are primarily used when you click the if button to limit the cases affected by your transformation.

< (less than)
> (greater than)
<= (less than or equal to)
>= (greater than or equal to)
= (equal to)
~= (not equal to)
& (Boolean AND)
| (Boolean OR)
~ (Boolean NOT)

Finally, the keypad contains a button with parentheses ( ). Clicking this button inserts a pair of parentheses into your formula, which can be used to tell SPSS which parts of your formula should be evaluated first.
As with the list of variable names, you do not have to use the keypad to use these functions - you can get the same results by typing the formula you want directly into the box labeled Numeric expression.

The right-hand part of the screen contains a list of functions that you can include in your formulas. There is a complete list of the functions that you can use in the box labeled Functions. Double clicking a function in this list will add it to your formula, with question marks in place of where you would need to insert the names of actual variable names. This can be handy if you find it difficult to remember the names of the functions you want to use. However, you do not have to use this list if you do not want to . you can type in the functions directly into your formula by hand. Below are some commonly used functions you can use in your formula.

. mean(var1, var2, …) . provides the average of the variables in the parentheses
. sum(var1, var2, …) . provides the sum of the variables in the parentheses
. sqrt(var) . provides the square root of the variable in parentheses
. lg10(var) . provides the base 10 logarithm of the variable in parentheses
. ln(var) . provides the natural logarithm of the variable in parentheses

You can right-click any function in the list to find out more about it.

Recode
The Recode procedure is typically used with transformations involving categorical variables. It is the best option when you want to create a categorical distinction based on an existing numeric variable (such as a median split), when you want to combine some of the categories in an existing categorical variable, or when you simply want to change the values assigned to an existing categorical variable.

In general it is recommended that you use numbers to code different levels of your categorical variables in SPSS. Although SPSS variables can have letters has values (these types of variables are called .string. variables), there are several important analysis that can only work with numeric variables, even if the variable itself is categorical.

Whenever you work with the Recode procedure you must choose whether to recode Into Same Variables or to recode Into Different Variables. If you choose to recode Into Same Variables then the result of your transformation will replace the values of your original variable. If you choose to recode Into Different Variables then the result of your transformation will be placed into a new variable that you will have to name. We suggest that you always use Into Different Variables so that you can later choose to redo the transformation if you want.

To perform a median split

. Obtain the median of the variable as described in the section on Descriptive Statistics.
. Choose Transform then Goto Recode then Goto Into different variables.
. Select the original continuous variable and click the arrow button.
. Type the name of the new categorical variable in the box labeled Name.
. Click the Change button.
. Click the Old and New Values button.
. Click the radio button next to Range: Lowest through.
. Type the value of the median in the open box on the left side.
. Type the value for the low category in the box labeled Value on the right side.
. Click the radio button next to All other values.
. Type the value for the high category in the box labeled Value on the right side.
. Click the Continue button.
. Click the OK button.

To change the values of an existing categorical variable
. Choose Transform then Goto Recode then Goto Into different variables.
. Select the original categorical variable and click the arrow button.
. Type the name of the new categorical variable in the box labeled Name.
. Click the Change button.
. Click the Old and New Values button.
. You must tell SPSS how the values of the old categorical variable map . onto the values of the new variable. For each level of the old variable
> Make sure the radio button next to Value is selected.
> Type the value of the original variable in the open box on the left side.
> Type the corresponding value of the new variable in the box labeled Value on the right side. It.s perfectly acceptable to assign the same new value to several different old values.
. Click the Continue button.
. Click the OK button.

One nice feature of the Recode function is that it remembers the last set of recodes that you asked it to perform. If you recode a variable and then select the recode function again, you.ll see the Old then Goto New combinations from the prior transformation. This can be very useful if you need to apply the same recoding to a number of different variables. In this case you could simply
change the input variable and output variable and then run the transformation, leaving the old and new values the same.

Reverse coding
Reverse coding is a procedure where some questions in a survey are worded such that high values of a theoretical construct is reflected by high scores on the item, while other questions are worded such that high values of the same construct is reflected by low scores on the item.

Researchers do this to encourage respondents to actually pay attention to the questions they are reading. Unfortunately this means that you can’t determine the overall score for the scale simply by averaging the items. Instead you must first transform the items so that they are all oriented in the same direction. For example, all items might be scored such that large values indicate more of the construct. To do this, you would want to reverse code the items where small values indicated a greater amount of the construct. So, if the questions in the scale had values of 1 to 7, you would reverse code an item by changing its values in the following way:

 Old Value New value 1 7 2 6 3 5 4 4 5 3 6 2 7 1

While it would be possible to perform this transformation using the Recode procedure, there is a simple formula you can use to do the same thing using the Compute procedure. The formula is

new value = (scale minimum + scale maximum) – old value

In the current example, the scale minimum is 1 and the scale maximum is 7. Therefore, the formula we’d need to use would be 8 – old value. You can verify for yourself that this will produce the transformation described above. The formula will work for any possible scale minima and maxima, even if the scale has values less than zero.