Molly McPup

Introduction to Research Methods in Political Science:
The POWERMUTT* Project
(for use with SPSS)

*Politically-Oriented Web-Enhanced Research Methods for Undergraduates — Topics & Tools
Resources for introductory research methods courses in political science and related disciplines

SITE
MAP

COMPUTE

COMPUTE is used to create new variables or to modify the values of existing variables.

From the menu bar, click on “Transform” and “Compute.”  In the resulting dialog box, type in the name of the variable you wish to create or modify in the window on the left (under “Target Variable:”).  In the window on the right (under “Numeric Expression:”), enter the formula you wish to use to create or modify the variable.  You can type the formula directly.  You can also do so by moving variables into the Numeric Expression window from the list on the left, and/or by selecting arithmetic operations from the keypad provided by SPSS.  Then click on “OK.”

Note: Use the following guide for the most common operations:

Partial table of operations
SYMBOL
LETTERS
MEANING
     
+
Plus
-
Minus
*
Multiplied by
/
Divided by
**
Raised to the ______ power
<
LT
Less than
>
GT
Greater than
<=
LE
Less than or equal to
>=
GE
Greater than or equal to
=
EQ
Equal to
&
AND
And
|
OR
Or

Suppose, for example, that you had a dataset for the American states containing a variable called “kerry” (representing the number of votes received by John Kerry in the 2004 presidential election), and a variable called “bush” (the number received by George W. Bush), and you wished to create a new variable representing the percentage of the two-party vote received by Kerry.  You could type “pctkerry” in the left widow, and enter “100*kerry/(kerry+bush)” in the right window.

Sometimes, you may wish to create or modify a variable for only come cases.  If so, click on “IF” before clicking on “OK.”  Then click on “Include if case satisfies condition,” and enter the formula for that condition in the right window and then click on “Continue.”

For example, if you wished to create a new variable to represent, in each state, the winning candidate’s percentage of the two-party vote, you could do so with a combination of two COMPUTE operations.  In the first, you would create a new target variable (calling it, let us say. “pctwin”), enter the expression “100*kerry/(kerry+bush),” click on “IF” and enter the expression “kerry>bush.”  In the second, the main numeric expression would be “100*bush/(kerry+bush)” and the “if” condition would be “bush>kerry.”

Any time that you are creating a new variable with a combination of COMPUTE operations (or a mix of COMPUTE and RECODE operations, be sure that you have defined a numeric expression for all cases.  Any cases not defined will automatically be assigned a system missing (sysmis) value.

In variable view, add variable labels and, if appropriate, value labels and missing values.

 


Last updated April 28, 2013 .
© 2003---2013  John L. Korey.  Licensed under a  Description: Creative Commons License Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.