You are on page 1of 33

Introduction to SPSS

-- Assessing SPSS (v)


-- Data Transformation (v)

Statistics
Forest 2031 (605 26210)
Assessing SPSS
● NTU VDI 臺大虛擬桌面系統 (https://vdi.ntu.edu.tw或安裝VMware
Horizon Client)
● 連線伺服器名稱:vdi.ntu.edu.tw ➔ 請選擇NTUCC登入
● Search SPSS ➔ and click on SPSS 22
● Java(TM) Platform SE binary ➔ 按「取消」
● 是否要允許公開、私人和網域網路存取此應用程式➔ 按「取消」
● Unicode 模型➔ 選擇「使用Unicode編碼」
● 選擇檔案➔ 按「取消」
Change to English Version of SPSS
● Edit編輯➔ Options選項➔
Language語言➔輸出:英文,
使用者介面:英文,
語言環境:OS輸入法系統.
➔ 確定
Entering Data in the Data Editor
The Data Editor has two “views”– Data View & Variable View.

● You can shift from one


view to the other by
clicking on the tabs in
the lower left of the
Data Editor window.

Data View Variable View


Entering Data in the Data Editor
Type the data given in the table into the Data view of the Data
Editor.
Use the arrow keys and/or ENTER to move about in the window.
Note that each column in Student ID Housing Sex Status Quiz1 Quiz2 Quiz3
which data are entered is 1 1 1 1 80 75 87
names automatically 2 1 1 2 51 999 999
3 1 2 2 91 85 999
(var00001, var00002, etc) 4 2 1 3 96 79 91
5 2 2 0 79 82 75
6 2 2 1 83 90 92
7 1 1 1 85 87 89
8 1 2 2 73 76 81
9 1 3 3 93 94 86
10 2 2 1 100 90 92
Naming Variables
(1) When you have completed entering the numbers, you
need to assign new names to the variables and specify
Missing Values codes.
(2) To do so, shift to the Variable View by clicking on that
tab in the lower left corner of the screen.
(3) Here, we have seven variables: ID, Housing, Sex, Status,
Quiz1, Quiz2, and Quiz3
(4) In the column headed “Name”, click on the first box
(the one labeled VAR00001), and type ID. Press ENTER
or move down the column using the arrow key and
entering the remaining variable names.
Codebook
A Codebook is an instruction to describe full variable names,
SPSS variable names, and coding instructions. The missing
values will also be indicated in the coding instructions.

Codebook
Full variable name SPSS variable name Coding instructions
Student ID ID subjuect identification number
Housing Housing 1=off campus, 2=on campus
Gender Sex 1=male, 2=female, 3=no information
Student Status Status 1=Undergraduate, 2=Master, 3=Doctoral, 0=no information on status
Quiz1 Score Quiz1 Actual score, 999=No quiz score available
Quiz2 Score Quiz2 Actual score, 999=No quiz score available
Quiz3 Score Quiz3 Actual score, 999=No quiz score available
Missing Values
1. The variables of Id and Housing have no missing data indicated, but for the
variable Sex, a code of 3 means that there is no information on the subject’s
gender.
2. To specify 3 as the missing value for Sex, in that
row, click on the box in the column labeled Missing,
and click again on the shaded box that appears.
In the window that opens:
Click on Discrete missing values
Type in 3 in the first box
Click OK
3. Go on specify Missing Values for Status, Quiz1,
Quiz2, and Quiz3 in the same way.
4. After you enter the data into the Data Editor,
remember to save it for future use.
Logging Commands on Your Output
When you ”point and click” in SPSS, commands are generated and
issued to the computer. You will find it useful to print these as part of
your output and to learn to read the interpret these commands since
they are a record of what you have done.
To do this, do the following before you begin your analysis:

Click on Edit
Select and click on Options
Click on the tab marked Viewer
Check the box in the lower left corner for Display command in the log
Click OK
Running SPSS Tasks using “Point-and-Click”
Once you have entered your data, you are ready to run an SPSS job.
For the first practice, you will learn to run two SPSS tasks or procedures.
IBM SPSS Statistics Data Editor
Task 1: CASE SUMMARIES

From the task bar at the top of


the Data Editor window
Click on Analyze
Drag to Reports
Click on Case Summaries
Task 1: Case Summaries

This will open a dialog box called


Summarize Cases. A sub-box to the
left lists the variables: Select all
seven variables. To do this click on
ID, drag down to Quiz3
(highlighting all variable names),
and click the upper right arrow
button in the middle of the dialog
box. All seven variable names
should appear in the Variables sub-
box on the right. Then, click OK.
Task 1: Case Summaries
Task 2: Frequencies
From the task bar in the Viewer window IBM SPSS Statistics Viewer
Click on Analyze
Drag to Descriptive Statistics
Click on Frequencies
This will open a dialog box called
Frequencies. A sub-box to the left lists the
variables: You will want to select all of the
variables except ID. To do this click on
Housing, drag down to Quiz3 (highlighting
six variable names), and click the right
arrow button in the middle of the dialog
box. The six variable names should now
appear in the Variables sub-box on the
right. DO NOT click OK, at least not yet.
There are some additional steps.
Task 2: Frequencies
In the Frequencies dialog box:
Click on Statistics (the little box on the right
top).
A dialog box called Frequencies: Statistics will
appear.
Click on (or check) each of the following:
Mean, Median, Mode, Sum, Std. deviation,
Variance, Range, Minimum, Maximum, S.E.
mean, skewness, Kurtosis
Click Continue
You will return to the frequencies dialog box.
Click OK.
SPSS will now display the frequencies directly
below the case summaries in the Viewer
window for your viewing pleasure.
Task 2: Frequencies
Task 3-1: Data Transformation: Recode
(Point and Click Methods)
RECODE is used to change the codes of a variable.
e.g., suppose that you want to change “Status” from a
3-category variable to a 2-category variable as follows:

Status Status2
1 Undergraduate 1 Undergraduate
2 Master 2 Graduate
3 Doctoral
Task 3-1: Data Transformation: Recode
(1) Click
Transform ➔ Record into Different Variables
(2) Specify the Old Variable Name in the box marked “Numeric Variable ➔ Output Variable”
(3) Give a name: Status2 and Label: Status2 to the new variable in the box marked “Output Variable”.
(4) Click “Change”.
(5) Click on “Old and New Values”. The screen changes to ….
Task 3-1: Data Transformation: Recode
(5) Click on “Old and New Values”. The screen
changes to ….
(6) Specify Old Value.
(7) Specify New Value.
(8) Click “Add”.
(9) Repeat steps (6) (7) (8) as needed.
(10) Click “Continue”. Screen returns to
previous window.
(11) Click “OK”.
Task 3-2: Data Transformation: Recode

RECODE can also be used to convert one or more


quantitative variables to categories.
e.g., suppose that you want to change the three quiz scores
from individual scores to grouped data:

90-100 = 1
80-89 = 2
70-79 = 3
< 70 = 4
Task 3-2 : Data Transformation: Recode
(1) Click
Transform ➔ Record into Different Variables
(2) Specify the Old Variable Name.
(3) Give a name to the new variable.
(4) Click “Change”.
(5) Repeat steps (2) (3) (4) as needed.
Task 3-2: Data Transformation: Recode
(6) Click on “Old and New Values”.
The screen changes to …
(7) Specify range of old values.
(8) Specify new value.
(9) Click “Add”.
(10) Click “Continue”. Screen returns to
previous form.
(11) Click “OK”.
Task 3-2: Data Transformation: Recode
(12) Go back to the Data Editor, and you will find new variables being added here.
Task 4: Transformation: COMPUTE
(Point and Click Methods)
COMPUTE allows us to calculate new variables from existing variables.
E.g., suppose that we want to calculate the
mean of the three quiz scores for each
student in the data set.

(1) Click
Transform ➔ Compute Variable
(2) Type in a name (i.e., average) for the new variable
in the box marked “Target Variable”.
(3) Enter the “Numeric Expression” for calculating the
new variable (the Target Variable) from existing
variables in the data set. You can type the
expression or use the symbol and number keys to
indicate the calculation. If you don’t know what a
symbol means, just click on it for a description.
(4) Press “OK”.
Task 4: Transformation: COMPUTE
(5) Go back to the Data View, and you will see a new variable listed as “average” with
values computed by the numeric expression.

Due to Missing Data


Task 5-1: Transformation: COMPUTE IF…
(Point and Click Methods)
COMPUTE IF… allows us to apply data transformations to
selected subsets of cases using conditional expressions.
e.g., To change “Status” from a 3-category variable to a 2-
category variable which we will call “Status 2”.

Status Status2
1 Undergraduate 1 Undergraduate
2 Master 2 Graduate
3 Doctoral · Missing
0 Missing Data
Task 5-1: Transformation: COMPUTE IF…

(1) Click
Transform ➔ Compute Variables
(2) Enter a name (i.e., Status 2) for the
new variable (Target Variable).
(3) Enter Numeric Expression (i.e., 1)
(here it is a single number).
(4) Click “IF…”.
Task 5-1: Transformation: COMPUTE IF…
The screen changes to…
(5) Click on “Include if case satisfies
condition”.
(6) Specify condition (i.e., “status=1”).
(7) Click “Continue”. Screen returns to
previous
format.
(8) Click “OK”.
(9) Repeat for Status2=2
(If…) status=2 or status=3
Task 5-1: Transformation: COMPUTE IF…
(10) Check by Analyze ➔ Reports ➔ Case
Summaries
Look only at the relevant old and new
variables (here status and status 2).
Task 5-2: Data Transformation: COMPUTE IF…
(Point and Click Methods)
COMPUTE IF… can build a new categorical variable from other
variables.
Sex Sexstat
1 Male 1 Undergraduate male
2 Female 2 Undergraduate female
3 Missing 3 Graduate male
Status 4 Graduate female
1 Undergraduate · Missing
2 Master
3 Doctoral
0 Missing
Task 5-2: Transformation: COMPUTE IF…
(1) Click
Transform ➔ Compute Variable
(2) Specify target variable name (i.e.,
Sexstat).
(3) Indicate Numeric Expression of target
variable (i.e., “1”)
(4) Click “If…”.
Task 5-2: Transformation: COMPUTE IF…
The screen changes to…
(5) Click on “Include if case satisfies condition”.
(6) Specify condition (i.e., Sexstat=1 when ”Sex=1
& Status=1”).
(7) Click “Continue”. Screen returns to previous
format.
(8) Click “OK”.
(9) Repeat for Sexstat=2 (If…) Sex=2 & Status=1
Sexstat=3 (If…) Sex=1 & Status=2 or Status=3
Sexstat=4 (If…) Sex=2 & Status=2 or Status=3
Task 5-2: Transformation: COMPUTE IF…
(10) Check by running Case Summaries
Analyze ➔ Report ➔ Case Summaries
Task 5-2: Transformation: COMPUTE IF…
(11) List variables is another useful way to check if SPSS has successfully created a new
variable. To do so, you need to open the Syntax Editor
File ➔ New ➔ Syntax
(12) After you open a Syntax Editor window, you can write your syntax directly in this
window. Here we want to check the variable of Sexstat, so write the following Syntax:
List Sexstat
/CASES FROM 1 to 10
/FORMAT NUMBERED.
(3) Click Run Selection

You might also like