An Interactive Tutorial for SPSS 10.
0 for Windows
Computing Variables
by
Julia Hartman
Next
1
Copyright 2000, Julia Hartman
Computing Variables:
Introduction
According to SPSS Help, the Compute
Variable command:
computes values for a variable based on
numeric transformations of other variables.
Next
2
Copyright 2000, Julia Hartman
Computing Variables:
Introduction
According to SPSS Help, using the Compute Variable
command:
You can compute values for numeric or string (alphanumeric)
variables.
You can create new variables or replace the values of existing
variables. For new variables, you can also specify the variable
type and label.
Next
3
Copyright 2000, Julia Hartman
Computing Variables:
Introduction
According to SPSS Help, using the Compute Variable
command:
You can compute values selectively for subsets of data based
on logical conditions.
You can use over 70 built-in functions, including arithmetic
functions, statistical functions, distribution functions, and
string functions.
Next
4
Copyright 2000, Julia Hartman
Computing Variables:
Introduction
The sections of this tutorial explain how to:
Compute a new variable by assigning a value
(setting it equal to zero)
Use selective criteria to compute a value
Compute a new variable by using a formula
(multiplying two variables)
Next
5
Copyright 2000, Julia Hartman
Computing Variables:
Introduction
This tutorial:
creates a new variable, fdummy, with a value of zero
sets fdummy = 1 for females
creates a new (dummy) variable, fgpa, by
multiplying fdummy by the existing variable totcum
(total cumulative undergraduate gpa)
Next
6
Copyright 2000, Julia Hartman
Computing Variables:
Computing a New Variable
To compute a new variable:
In the menu, click
Transform
7
Copyright 2000, Julia Hartman
Computing Variables:
Computing a New Variable
To compute a variable:
In the menu, click
Transform
Point to Compute
8
Copyright 2000, Julia Hartman
Computing Variables:
Computing a New Variable
To compute a variable:
In the menu, click
Transform
Point to Compute
and click.
9
Copyright 2000, Julia Hartman
Computing a New Variable:
Naming the New Variable
To assign a value
to the variable,
you must type the
variable name in
the box labeled
Target Variable.
Next
10
Copyright 2000, Julia Hartman
Computing a New Variable:
Assigning a Value
You cant type in this
tutorial, so the name
of the new variable
(fdummy) has already
been entered.
To set the value of
fdummy to zero,
click the 0 button.
11
Copyright 2000, Julia Hartman
Computing a New Variable:
Assigning a Value
The zero appears in
the box labeled
Numeric Expression,
resulting in the
formula fdummy = 0.
Click the OK button
to complete the
transformation.
12
Copyright 2000, Julia Hartman
Computing Variables:
Computing Variables Selectively
The preceding steps added the variable fdummy
to the data file and assigned a value of zero (0) to
all cases (records).
Next, the value of fdummy will be changed to
one (1) for all females in the dataset.
Next
13
Copyright 2000, Julia Hartman
Computing Variables:
Computing Variables Selectively
To compute a new value for an existing variable:
In the menu, click
Transform
14
Copyright 2000, Julia Hartman
Computing Variables:
Computing Variables Selectively
In the menu, click
Transform
Point to Compute
15
Copyright 2000, Julia Hartman
Computing Variables:
Computing Variables Selectively
In the menu, click
Transform
Point to Compute
and click.
16
Copyright 2000, Julia Hartman
Computing Variables Selectively:
Specifying the Target Variable
In SPSS, you would
type the variable
name in the box
labeled Target
Variable, but that
doesnt work in this
tutorial.
Next
17
Copyright 2000, Julia Hartman
Computing Variables Selectively :
Specifying the Target Variable
In this graphic, the
name of the target
variable (fdummy) has
already been entered.
To change the value
of fdummy for
selected cases, click
the If button.
18
Copyright 2000, Julia Hartman
Computing Variables Selectively :
If Cases
To set the
selection criteria,
click the button
labeled
Include if case
satisfies condition:
19
Copyright 2000, Julia Hartman
Computing Variables Selectively :
If Cases
To set the
selection criteria
to gender = 1
(female), click
Gender of Student
[gender] in the
variable list.
20
Copyright 2000, Julia Hartman
Computing Variables Selectively :
If Cases
Move gender to
the criteria box by
clicking the arrow.
21
Copyright 2000, Julia Hartman
Computing Variables Selectively :
If Cases
Move gender to
the criteria box by
clicking the arrow.
Click the button
with the equal sign,
22
Copyright 2000, Julia Hartman
Computing Variables Selectively :
If Cases
Move gender to
the criteria box by
clicking the arrow.
Click the button
with the equal sign,
then click the 1
button (value for
female in the file).
23
Copyright 2000, Julia Hartman
Computing Variables Selectively :
If Cases
Values will be
changed only if
gender = 1.
Click the Continue
button.
24
Copyright 2000, Julia Hartman
Computing Variables Selectively :
Assigning a Value
The condition
gender = 1 is
displayed next
to the If
button.
Next
25
Copyright 2000, Julia Hartman
Computing Variables Selectively :
Assigning a Value
To set the value of
fdummy =1 if
gender = 1, click
the 1 button.
26
Copyright 2000, Julia Hartman
Computing Variables Selectively :
Assigning a Value
The 1 appears in the
box labeled
Numeric Expression.
Click the OK button
to complete the
transformation.
27
Copyright 2000, Julia Hartman
Computing Variables Selectively :
Assigning a Value
The dialog box
warns that the value
of fdummy will be
changed.
Click the OK button
permit the change.
28
Copyright 2000, Julia Hartman
Computing Variables:
Using a Formula
The preceding steps:
1. Added the variable fdummy to the data file and
assigned a value of zero (0) to all cases.
2. Changed the value of fdummy to one (1) for all
females in the dataset.
Next
29
Copyright 2000, Julia Hartman
Computing Variables:
Using a Formula
Now we will use the new variable fdummy
and the variable totcum (total cumulative
undergraduate gpa) to create another new
(dummy) variable, fgpa, by multiplying
fdummy by totcum.
Next
30
Copyright 2000, Julia Hartman
Computing Variables Using a Formula:
Computing a New Variable
To compute a new variable:
In the menu, click
Transform
31
Copyright 2000, Julia Hartman
Computing Variables Using a Formula :
Computing a New Variable
To compute a variable:
In the menu, click
Transform
Point to Compute
32
Copyright 2000, Julia Hartman
Computing Variables Using a Formula :
Computing a New Variable
To compute a variable:
In the menu, click
Transform
Point to Compute
and click.
33
Copyright 2000, Julia Hartman
Computing a New Variable Using a Formula :
Naming the New Variable
To assign a value
to the variable,
you must type the
variable name in
the box labeled
Target Variable.
Next
34
Copyright 2000, Julia Hartman
Computing a New Variable Using a Formula :
Naming the New Variable
In this graphic, the
name of the new
variable (fgpa) has
already been entered.
The variable fgpa will
be calculated by
multiplying totcum
by fdummy.
Next
35
Copyright 2000, Julia Hartman
Computing a New Variable Using a Formula :
Entering a Formula
Scroll down the
variable list to
totcum, which is
labeled
UNDERGRAD GPA,
TOTAL-CUMULATIVE
36
Copyright 2000, Julia Hartman
Computing a New Variable Using a Formula :
Entering a Formula
Scroll down the
variable list to
totcum, which is
labeled
UNDERGRAD GPA,
TOTAL-CUMULATIVE
and click.
37
Copyright 2000, Julia Hartman
Computing a New Variable Using a Formula :
Entering a Formula
Click the arrow to
move totcum to the
box labeled
Numeric Expression.
38
Copyright 2000, Julia Hartman
Computing a New Variable Using a Formula :
Entering a Formula
Click the * button
for multiplication.
39
Copyright 2000, Julia Hartman
Computing a New Variable Using a Formula :
Entering a Formula
Click the * button
for multiplication.
Then scroll down
the variable list to
fdummy
40
Copyright 2000, Julia Hartman
Computing a New Variable Using a Formula :
Entering a Formula
Click the * button
for multiplication.
Then scroll down
the variable list to
fdummy
and click.
41
Copyright 2000, Julia Hartman
Computing a New Variable Using a Formula :
Entering a Formula
Click the arrow to
move fdummy to the
box labeled
Numeric Expression.
42
Copyright 2000, Julia Hartman
Computing a New Variable Using a Formula :
Entering a Formula
The resulting
formula is:
fgpa =
totcum * fdummy.
Click the OK button
to create the new
variable.
43
Copyright 2000, Julia Hartman
An Interactive Tutorial for
SPSS 10.0 for Windows:
Computing Variables
Click one of the following:
Repeat this tutorial
Repeat a section of this tutorial
Return to the list of tutorials
44
Copyright 2000, Julia Hartman