Professional Documents
Culture Documents
Section 1: Introduction
Overview of SPSS for Windows
Starting SPSS
Data Entry and formatting in SPSS
Data importing from Excel and ASCII Files
Section 2: Modifying and Organizing Data
Retrieving Data
Inserting cases and Variables
Computing new variables
Recoding variables
Banding values
Sorting and merging variables /Cases
Keeping and Dropping cases
Collapsing and Transposing Data
Listing of Cases
INTRODUCTION TO SPSS
SPSS:
stands for Statistical Package for the Social Sciences.
used for conducting statistical analyses,
manipulating data, and generating tables and
graphs that summarize data
Statistical analyses range from basic descriptive
statistics to advanced inferential statistics
contains several tools for manipulating data,
including functions for recoding data, computing
new variables , merging and aggregating datasets
has a number of ways to summarize and display data
in the form of tables and graphs .
Count…
SPSS for Windows consists of five different windows, each of which is
associated with a particular SPSS file type
These are
Data editor: open at start-up and is used to enter and store data in a
spreadsheet format.
Output viewer: opens automatically when you execute an analysis or
create a graph using dialog box or command syntax to execute a
procedure. Results of all statistical analyses and graphical displays of
data.
Syntax Editor: a text editor where you compose SPSS commands and
submit them to the SPSS processor. All outputs from this command
appear in the output view
Chart Editor
Pivot Table Editor
Count…
Each windows in SPSS has their own menus
The common menus are
File
Edit
View
Analyses
Graphs
Window
Help
Count…
Toolbars in SPSS for Windows:
Each SPSS window has its own toolbar that provides
quick and easy access to common task
Toolbars provide a brief description of each tool
when you put the mouse pointer on the tool
Starting SPSS
To start SPSS:
From the Windows Start menu choose:
Programs
SPSS for Windows…
A small window will appear. This window has several choices with different
questions and options.
Run tutorial
Type in Data
If you choose type in data, you will get Data Editor Window
Entering data in SPSS
Variables in SPSS:
used to represent the different types of data that you have
compiled
come in many different types, including numbers, strings,
currency, and dates.
The variable name:
Variable in a given file must be unique, duplication is not
allow
should not begin with any special characters such as
numerals, comma, period, inequality symbols etc.
Do not end variable names with an underscore and a period.
Names are not case sensitive.
The latest versions of SPSS can accept variable names with
length greater than 8 characters
Count…
To write your variable name:
Use Ctrl+T
Then write the name of the variable under the “Name”
column
Note: To find the rules for naming variables press: Help,
Topics, Index. Then enter the phrase variable names:
rules. Then press the Display button
Type
Under “type” column click on the gray small box then the
variable type box will come to the foreground
There're eight choices select the one that is
appropriate to variable under consideration
Using numeric, dollar and custom currency is not that
much quite different
Label
The label of a variable is a string of text to
identify in more detail what a variable
represents
Unlike the name, the label is limited to 255
characters and may contain spaces and
punctuation
To change or edit a variable label, simply
click anywhere within the cell
Values
A value label is a label assigned to a particular value
of a variable
You are most likely to use value labels for nominal or
categorical data
Click on the gray box as usual then “value labels”
dialog box appear
Use the following steps to work with this dialog box
Click in the Value field to type a specific numeric value
Click in the Label field to type the corresponding label
Click on the Add button to add this pair of value and label
to the list
Count…
You can remove a pairing created above by
clicking on that pair and then clicking on the
remove button
Similarly, you can change pairing by clicking on
the pair, then typing in a new value, a new label,
or both; then, you click on the Change button
When you are satisfied with the definitions of
each value, click on the OK button
Columns
The column size indicates how much space is
allocated to a particular variable
Don't confuse this one with width, which
indicates how many digits of the number will
be displayed
Align and Measure
Align indicates whether the information in the
Data View should be left-justified, right-
justified, or centered
SPSS does not differentiate between interval
and ratio levels of measurement, both of these
quantitative variable types are lumped together
as "scale”
Entering the Data
You may also use the Up, Down, Left, and
Right arrow keys to enter values and move to
another cell for data input
To edit existing data points (i.e., change a
specific data value), click in the cell, type in
the new value, and press the Tab, Enter, Up,
Down, Right, or Left arrow keys
Example
1. The following small data set consists of four variables namely, Agecat,
gender, accid and pop.
Where agecat is a categorical variable created for age.
1= ‘ Under 21 ‘ 2= ‘ 21-25’ , 3. = ‘ 26-30’
Gender: 0 = ‘Male’ and 1= ‘Female’
Accid and Pop are numeric.
After defining these variable in a data editor window, enter the following
data for the variables agecat, Gender, Accid and Pop respectively. Your
data should appear as given below. Save the data set as trial1.sav.
1 1 57997 198522
2 1 57113 203200
3 1 54123 200744
1 0 63936 187791
2 0 64835 195714
3 0 66804 208239
Example 2
2. Create a data set called Trial2.sav from the following data. The data set has the following
variables :
I. Subject numeric width =2, right aligned and columns = 8
II. anxiety : numeric width =2, right aligned and columns = 8
III. tension : numeric width =2, right aligned and columns = 8
IV. Score : numeric width =2, right aligned and columns = 8
V. Trial : numeric width =2, right aligned and columns = 8
In addition there is no value levels for each of the above variables.
After completing the definition of the above variables, type in the following
data into your data editor window so that your data appears as given below.
1 1 1 18 1
1 1 1 14 2
1 1 1 12 3
1 1 6 4 1
Cont
2 1 1 19 1
2 1 1 12 2
2 1 1 8 3
2 1 1 4 4
3 1 1 14 1
3 1 1 10 2
3 1 1 6 3
3 1 1 2 4
4 1 2 16 1
4 1 2 12 2
4 1 2 10 3
Exercise
. Given below is an example of a questionnaire, suppose you have information on
several of such questionnaires. Prepare a data entry format that will help you to
enter your data to SPSS.
Examples of questionnaire Design
Name ____________________________________________________________
Age ______________ ____________Sex ________________________________
City
__________________________________________________________________
Marital Status Married Single
Family Type Joint Nuclear
Family Members Adults Children
Family Income less than 10,000 10, 000 to 15,000 15,000-
20,000
More than 20, 000
Date:______________
Cont…
1.What kind of food do you normally eat at home?
North Indian South Indian Chinese Continental
2 How frequently do you eat out?
In a week once Twice Thrice More than thrice
3. You usually go out with:
Family Friends Colleagues Others _______________
4. Is there any specific day when you go out?
Weekdays Weekends Holidays Special occasions
No specific days
5. You generally go out for
Lunch Snacks Dinner Party/Picnics
6. Where do you usually go?
Restaurant Chinese Joint Fast food joint others __________
7. Who decide on the place to go?
Husband Wife Children Others ______________
8. How much do you spend on eating out (one time)?
Below 200 200-500 500-800 More than 800
Cont…
9. What did you normally order?
Pizza Burgers Curries and Breads Soups
Pasta
10. The price paid by you for the above is
10.1 Pizza: Very high A little bit high Just right
10.2 Burgers: Very high A little bit high Just right
10.3 Curries and Breads: Very high A little bit high
Just right
10.4 Soups: Very high A little bit high Just right
10.5 Pasta: Very high A little bit high Just right
Importing Data From Excel Files
Data can be imported into SPSS from Microsoft Excel
may want to save your data as an Excel file, then import it into SPSS.
To open an Excel file, select the following menu options from the menu
in the Data Editor window in SPSS.
File
Open...
and then, select the desired location on disk using the Look in option.
Next, select Excel (*.xls) from the Files of type drop-down menu.
The file you saved should now appear in the main box in the Open File
Retrieving data
Inserting and deleting Cases and Variables
Computing New Variables
Recoding Variables
Sorting Cases
Selecting Cases
Listing Cases
Merging Files
Aggregating Files
Restructure Data
Transpose all data
RETRIEVING DATA
We can retrieve A. sav data file from any directory in our personal computer from
floppy disk or any other removable disk
To retrieve a data file from floppy disk, we select from application window menu
bar
File
Open…Data
Assuming the data type you want is on the floppy disk and has been saved previously
by SPSS, open the drives drop down list and click on the icon for the drive a: All the
files on drive A ending with . SAV extension will be listed in the files list.
Click on the name of the file you want to retrieve, and it will appear in the file
name box.
Click on the Ok button on the right hand side of the dialogue box.
The file will then be put into the Data Editor Window, and its name will be the title
of that window.
Inserting and Deleting Cases and Variables
Open Employee Data.sav file
You may want to add new variables or cases to an
existing dataset
To insert a new variable click on the variable name to
select the column in which the variable is to be inserted
To insert a case, select the row in which the case is to
be added
The selected row and column is being highlighted
Count…
Next use the insert option available in the DATA menu
in the data editor
Use either “insert variable” or “insert case” as needed
This produce an empty row and column
Note that the existing cases and variables will be shifted
down or to the right, respectively.
To delete cases and variables highlight the desired row
and column then use DELETE key or use DELETE
option in Edit menu
Computing New Variables
You may want to modify the values of the variables in your
dataset
From employee data, we need to create new variable which
contains the difference between beginning and current salary
To do this go to TRANSFORM menu and select COMPUTE
then “computed variable” dialog box appears
Write the new variable on TARGET VARIABLE, say
“salchng” and describe your variable by click on TYPE &
LEBEL tab
Select “salary” and “salbegin” from the left side box
Write salary-salbegin in NUMERIC EXPRESSION box
Computing New Variables (Count…)
continuous variables
there are two options for recoding variables in the Recode submenu
those are :
Into Same Variables:This option changes the values of the existing variables
Into Different Variables: This option changes the values of the existing
variables
5. After identifying one value category or range, enter the value for the
new variable in the New Value box.
6. Click ADD and repeat the process until each value of the new
variable is properly defined .
( See Figure Below ). Recode: Old and new values
Recoding Variables (Count…
Banding Values
taking two or more contiguous values and grouping them into the same
category.
Use of Banding:
Create a categorical variable from a scale variable.
Combine several response categories into a single category.
Create a new variable that is the computed difference between two existing
variables.
Calculate the length of time between two dates.
Procedure:
From the menus in the Data Editor window choose:
Transform
Visual Bander...
Drag and drop the desired variable from the Variables list into the Variables to
Band list, and then click Continue.
In the main Visual Bander dialog box, select the desired variable in the Scanned
Variable List.
Click Make Cutpoints.
Select Equal Width Intervals.
Click Apply.
Sorting Cases
allows you to organize rows of data in ascending or descending order on the
interested to sort the data based on the variable “Jobcat” which refers to the
category of employment. The procedure for sorting will be as follows:
Data
Sort Cases...
A small dialog box with header Sort Cases will pop up.
Then choose whether the data are sorted in ascending or descending order,
similarly the data could also be sorted by more than one variable. For
example, within job category, cases could be listed in order of their salary.
Sorting Cases (count...)
The dialog box that results from selecting Sort Cases
presents as follow:
Listing Cases
You may sometime want to print a list of your cases and the values of
variables associated with each case, or perhaps a list of only some of the cases
and variables
The procedure for doing this cannot be performed using dialog boxes and is
Add variables:
adds new variables on the basis of variables that are common
to both files.
In this case, we need to have two data files. Each case in the
one file corresponds to one case in the other file. In both files
each case has an identifier, and the identifiers match across
cases.
Merging Files(count…)
Example, Given below we have a file containing dads and we
have a file containing faminc.
Dads
famid name Inc 2
Art 22000 1 Bill
30000 3 Paul
25000
Faminc
Famid faminc96 faminc97 faminc98 3
75000 76000 77000 1
40000 40500 41000 2
45000 45400 45800
Merging Files(count…)
To merge the two files the procedure is as follows:
First sort both data sets by famid.
Select :
Data
Merge files … add variables and select the file faminc.
following steps:
1. Select Data and then AGGREGATE
Break variable: The top box, labeled Break Variable(s), contains the variable within
which other variables are summarized. This is something like classification variable.
Aggregated Variables: contains the variables that will be collapsed.
Number of cases: This option allows us to save the number of cases that were
Suppose, the data that are arranged in groups of related columns. Our interest
is to restructure these data into groups of rows in the new data file. Then we
choose the option restructure selected variables into cases.