Top Banner
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
16

Day1, session ii&iii- spss

Apr 13, 2017

Download

Education

Abir Hossain
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Day1, session ii&iii- spss

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

Page 2: Day1, session ii&iii- spss

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.

Page 3: Day1, session ii&iii- spss

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

Page 4: Day1, session ii&iii- spss

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

Page 5: Day1, session ii&iii- spss

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

Page 6: Day1, session ii&iii- spss

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 $.

Page 7: Day1, session ii&iii- spss

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

Page 8: Day1, session ii&iii- spss

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

Page 9: Day1, session ii&iii- spss

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

Page 10: Day1, session ii&iii- spss

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:

Page 11: Day1, session ii&iii- spss

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.

Page 12: Day1, session ii&iii- spss

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.

Page 13: Day1, session ii&iii- spss

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

Page 14: Day1, session ii&iii- spss

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:

Page 15: Day1, session ii&iii- spss

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

Page 16: Day1, session ii&iii- spss

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.