1. 1
Introduction to SPSS (Data Entry, Reading, Matching)
Day 1, Session II &II
M. Amir Hossain, Ph.D.
January 17, 2016
Starting SPSS
⢠SPSS stands for Statistical Package for Social Science. It is
used to manage and analyze data. In most of the Windows
operating systems, SPSS can be started from the Start Menu.
⢠Steps: Click on the Start menu at the bottom-left corner of your
screen. Point the cursor to Programs, point to SPSS for
Windows, and then click on SPSS 16.0 for Windows.
START > Programs > SPSS for Windows > SPSS 16.0 for Windows
2. 2
SPSS 16.0 for windows
will be opened.
If a dialog box appears, click
on Cancel or press the Esc
key from your keyboard. The
dialog box will disappear.
Now, the window you will
get is the data window
Starting SPSS
SPSS Menu and Syntax
ď We can perform our tasks in SPSS by issuing various
commands / instructions. These instructions can be issued
either using Menu or using Syntax.
ď Most of the commands can be issued from the menu, which is
apparently easier than the syntax. But syntax has the flexibility
when you deal with specific computation, customization, using
same command repeatedly and in many other situations.
3. 3
Various Types of Windows in SPSS
There are three types of windows in SPSS. These are:
ď Data window: Data window shows working data file and can be
used to enter new data or modify existing data. Data window
consists of a window which they call Variable View.
ď Syntax window: Used to write and execute commands.
ď Output window: Shows the output after a command is
successfully executed. It also shows possible error message if
the command is not recognized by SPSS.
Data Window
4. 4
Syntax Window
Syntax window is used
to write various SPSS
commands
To create a new syntax
file, follow the steps:
â˘Click on File menu
from the data window
â˘Point to New
â˘Then click on Syntax.
Output Window
5. 5
Various Types of FILES in SPSS
File Type Extension Purpose
SPSS data file
or SPSS type file or
Data file
SAV Stores data along with the descriptive information of
each variables and their values.
SPSS syntax file /
Command file
SPS Contains various commands and instructions to perform
various tasks. Sometimes it contains inline data.
Output file SPO Contains outputs / results generated after executing
commands through menu or syntax.
Raw Data file DAT / TXT ASCII data file. Contains data/information in raw
(unstructured) format
Excel file XLS Microsoft Excel file. Usually contains data.
Opening SPSS data files
Steps:
⢠First open SPSS data window.
⢠Then click on the File menu at the top left
corner of your screen. Point the cursor to
Open, point to Data.
File > Open> Data>Path of data file
6. 6
Data Entry in SPSS
⢠Data can be entered in SPSS data window or in Excel.
⢠Data Entry Using SPSS
⢠Step 1. Notice on the bottom left hand corner of the screen
that you can access either the Data View or Variable View
windows. To view one window or the other, simply click on
it. For now, in establishing the variables and their
characteristics, you should work in the Variable View
window.
Data Entry in SPSS
Step 2. In the space for Name, type the desired variable name.
Variable Names
ď Each variable must have a unique name. Variable names are stored in
the dictionary of an SPSS-format data file or working data file.
Observe the following rules when establishing variable names or
referring to variables by their names on commands:
ď The name must begin with a letter. The remaining characters can be
any letter, any digit, a period, or the symbols @, #, _, or $.
7. 7
Data Entry in SPSS
Variable Names
ď The period, underscore, and the characters $, #, and @ can be used
within variable names. For example, A._$@#1 is a valid variable
name.
ď Variable names cannot end with a period since the period may be
interpreted as a command terminator.
ď Variable names ending in underscores should be avoided, since such
names may conflict with names of variables automatically created by
a number of commandsâfor example, YEAR_ and DATE_ created by
the DATE command.
Data Entry in SPSS
ALL AND BY EQ GE GT LE LT NE NOT OR TO WITH
Variable Names
ď Blanks and special characters (for example, !, ?, â, and *) cannot be
used.
ď Each variable name must be unique; duplication is not allowed.
Variable names are not case sensitive.
ď Reserved keywords cannot be used as variable names. Reserved
keywords are
8. 8
Data Entry in SPSS
Step 3.
Press the Tab key and you will notice that SPSS
assigns default values to all of the settings. You
should go through the relevant column for that
particular variable. Clicking on a column will often
expose a shaded area. You can click on this to
pursue your options.
Data Entry in SPSS
Variable View Default
Type: Allows you to define the type of variable. Other
formats are comma, dot, dollar, string.
numeric
Width: Total number of characters (Maximum 40) 8
Decimals: Number of characters beyond the decimal point 2
Label: Allows you to list a more extensive label for your variable.
Eight character variable names are difficult to remember, and we
recommend that you always exercise the option of listing a more
descriptive label. Variable labels can be up to 256 characters
long.
none
9. 9
Data Entry in SPSS
Variable View Default
Value: Allows you to provide labels for the various levels of a
variable. This is particularly useful if your data file uses numeric
codes to represent non-numeric categories. For example, Sex has
two typesâmale or female. We may code male as â1â and female
as â2â. These are called values of the variable Sex.
none
Missing Values: Enables you to designate certain scores as
missing.
none
Align: Allows you to determine the alignment of your column right
Measure: Allows you to determine the kind of scale for that
particular variable
scale
Data Entry in SPSS
Create as many variables as necessary
10. 10
Data Entry using Excel
ď Open MS Excel program
[Start > Programs > Microsoft Excel]
ď In the worksheet, write the variable names
(following naming convention) column wise
ď Enter data
ď Save the file to your folder.
Importing Excel data file in SPSS data window
ď In the SPSS data window, follow
File > Open > Data
ďA new window will appear prompting
you to choose the File type to open.
ďChoose Excel (*.xls) type file
ďLocate your folder where you saved
the file.
ďClick Open
ďA new window will appear like this
figure:
11. 11
Importing Excel data file in SPSS data window
ď Choose appropriate worksheet and data range to import
data.
ď By default, all the data will be imported unless otherwise
stated.
ď If you like to import a particular section of data and
variables, indicate them in the Range field.
ď Suppose, you want to import only two variables ID and
Gender. Then, type A1:B6 in the range field
MERGING DATA FILES
Add Cases:
Add Cases merges the working data file with a second
data file that contains the same variables but different
cases. The two files must be identical in number of
variables and variable names. For example, you might
record the same information for customers in two
different sales regions and maintain the data for each
region in separate files.
12. 12
MERGING DATA FILES
Open one of the data files.
The cases from this file will appear first
in the new, merged data file.
From the menus choose:
You will then be prompted to select the
file that you wish to merge. Simply
double click on that file, and the
resulting dialog box will look something
like this:
Data>Merge files>Add cases
To Merge Files with the Same Variables and Different Cases
MERGING DATA FILES
Add Variables:
Add Variables merges the working data file with an
external data file that contains the same cases but
different variables. For example, you might want to merge
a data file that contains pre-test results with one that
contains post-test results.
13. 13
MERGING DATA FILES
Add Variables:
ď Cases must be sorted in the same order in both data files.
ď If one or more key variables are used to match cases, the two
data files must be sorted by ascending order of the key
variable(s).
ď Variable names in the second data file that duplicate variable
names in the working data file are excluded by default
because Add Variables assumes that these variables contain
duplicate information
MERGING DATA FILES
Open one of the data files.
The cases from this file will appear first
in the new, merged data file.
From the menus choose:
You will then be prompted to select the
file that you wish to merge. Simply
double click on that file, and the
resulting dialog box will look something
like this:
Data>Merge files>Add variables
To Merge Files with the Same Cases but Different Variables
14. 14
MERGING DATA FILES
ď Select Key Variables. We are matching cases on key variables. In this
example, we are using "subject" as the key variable. This basically
means that values for variables from both data files, will be matched
for each specific case.
ď Select the variables from the external file variables (+) on the
Excluded Variables list.
ď Select Match cases on key variables in sorted files.
ď Add the variables to the Key Variables list.
To Merge Files with the Same Cases but Different Variables
MERGING DATA FILES
ID Age Sex GPA
1 17 M 5
2 16 F 5
3 17 F 4.75
4 18 M 5
5 19 M 4.5
Enter the information in the SPSS data
window with the variable labels for
ID=âIdentification numberâ, Age=âAge of
the studentâ, Sex=âGender of the
studentâ and GPA =âGrade point
averageâ. The value labels for the
variable Sex considering M=Male and
F=female.
Save the SPSS data file as Student_1.
Suppose a teacher has information of 5 students as following:
15. 15
MERGING DATA FILES
ID Age Sex GPA
6 18 M 5
7 16 F 4.5
8 17 F 4.75
Enter the information in the SPSS data
window with the variable labels for
ID=âIdentification numberâ, Age=âAge of
the studentâ, Sex=âGender of the
studentâ and GPA =âGrade point
averageâ. The value labels for the
variable Sex considering M=Male and
F=female.
Save the SPSS data file as Student_2.
After few days he get information of another 3 students:
MERGING DATA FILES
Enter the information in the SPSS data
window with the variable labels for
ID=âIdentification numberâ, Marks=âMarks
obtained by the studentsâ.
Save the SPSS data file as Student_3
After final exam, the marks of the 8
students obtained in the math.
course are given in the table:
ID Marks
1 80
2 90
3 95
4 85
5 90
6 87
7 92
8 83
16. 16
MERGING DATA FILES
Exercise: Add Cases
Add the new 3 students to the old 5 students and
save the SPSS data file as Student.
Exercise: Add Variables
Add the variable âMarksâ to the previous data file
named Student and save it.