1. Ambo University
College of Medicine and Health Sciences
Department of Public Health
Eshetu Ejeta (BSc, MPH, PhD in Epidemiology)
2/14/2021 Prepared by: Dr. Eshetu Ejeta 1
2. Course Title: Introduction to computer and
application of software
Course number: COMP 5016
Cr.Hrs: 2
2/14/2021 Prepared by: Dr. Eshetu Ejeta 2
3. Introduction
• SPSS:
• Stands for Statistical Package for Social Science
• a computer package that will perform a wide variety of statistical
procedures.
procedures.
• Used to manipulate data, make graphs and perform statistical techniques
varying from mean to regression.
• Also used for data entry, however it doesn’t have any controlling
mechanism for errors, rather it is pretty good for data analysis
3
2/14/2021 Prepared by: Dr. Eshetu Ejeta
4. SPSS Windows
The data view Window
• Displays the actual data and any new variables you have created.
• Columns represent variables.
• Rows represent individual units (case) or groups of units that share
common values of variables
2/14/2021 Prepared by: Dr. Eshetu Ejeta 4
5. SPSS windows…
The variable view
• Contains the definitions of each variable in the data set, including
• Name of variables
• Type: Allows for various styles of displaying
• Type: Allows for various styles of displaying
• Label: Allows for longer description of variable name
• Values: Allows for longer description of variable levels
• Measures: Allows choice of measurement scale
• Other information
2/14/2021 Prepared by: Dr. Eshetu Ejeta 5
7. SPSS windows…
The output window
• is where we can see the results of our analysis/graph
• E.g. frequency distributions, cross-tabs, statistical tests, and charts
The syntax view
• It is SPSS commands
• It is SPSS commands
• When you’ll want to replicate your analysis.
• The best method of preserving the exact steps of a particular analysis
• Preserve the code used to generate any set of tables or charts.
• Syntax is basically the actual computer code that produces a specific
output.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 7
8. SPSS windows…
Pivot Table Editor window
• Used to modify the tables in the Output window to suit your
needs.
• To modify a table double-click on the table then the new window
will open (Pivot Table Editor).
• Use this editor to change the look of your table, the size, the fonts
used, and the dimensions of the columns
2/14/2021 Prepared by: Dr. Eshetu Ejeta 8
9. SPSS windows…
Chart Editor window
• Used to modify the appearance and format of your graph, change
the fonts, type, colors, patterns and line markers .
• Double click on the chart then the new window will open (Chart
• Double click on the chart then the new window will open (Chart
Editor window).
2/14/2021 Prepared by: Dr. Eshetu Ejeta 9
10. The main menu bar in SPSS
• The menu bar provides a series of “drop down” commands to perform
most essential SPSS functions. They are:
• File: the basic file management operations. e.g. opening, saving, and
printing files
• Edit: allows to perform editing functions on the current data set. e.g. cut,
• Edit: allows to perform editing functions on the current data set. e.g. cut,
copy, clear, undo changes and redo changes, insert variable, insert cases
• View: allows to change the current view of data and toolbar options. e.g.
grid lines, value labels.
• Data: deal with the configuration, defining, and management of data. e.g.
Define variable properties, sort data, merge files, split,
2/14/2021 Prepared by: Dr. Eshetu Ejeta 10
11. The main menu bar…
• Transform: allows to transform the data set you have entered. e.g.
generating new variables, recoding.
• Analyze: includes the main data analysis functions. e.g. descriptive
statistics, t-Tests, ANOVA, correlation, data reduction, regression
• Windows: allows to alter the appearance, format, position of the SPSS
• Windows: allows to alter the appearance, format, position of the SPSS
windows.
• Graph: allow you have different graph e.g. Bar chart, histogram
• Utilities
• Help: Opens a Microsoft Help window containing information on how to
use many SPSS features.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 11
12. The main menu bar……
• Utilities
• A summary of variable characteristics can be obtained from the Utilities drop-
down menu.
• The Variables… command a selected variable opens a dialogue box where
• The Variables… command a selected variable opens a dialogue box where
information can be requested for,
• while choosing File Info from the drop-down menu generates this information
for every variable in the Data View.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 12
13. Data Editor Toolbar
• A series of icons displayed horizontally across the page directly
below the Menu.
• If you do not see this toolbar, click View on the menu, select
Toolbars, and then click Data Editor.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 13
14. Preparing data file in SPSS
• It’s impossible to talk about SPSS (or any analysis program) without
talking about data and types of data
• In SPSS, before entering data, all the variables need to be defined in
the Variable View . To open new data view: File > New > Data >
2/14/2021 Prepared by: Dr. Eshetu Ejeta 14
15. Preparing Data File in SPSS …
Variable Names
• Each variable name must be unique (duplication is not allowed).
• Cannot begin with a special character (#, &)
• Cannot begin with a number. Must be begin with a letter
• No spaces
• No spaces
• Use under score if you want space (Age_Year) or
• UseCamelCase (e.g. FirstName)
• Names must be no longer than 8-12 characters
• Ending with a period should be avoided, since the period may be
interpreted as a command terminator.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 15
16. Preparing data file in SPSS …
Variable Names…
• Avoid ending in underscores since such names may conflict with
names of variables automatically created by commands and
procedures.
procedures.
• Can be defined with any mixture of uppercase and lowercase
characters.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 16
17. Preparing data file in SPSS …
Variable types
• Select certain settings to tell
SPSS what type of numbers or
SPSS what type of numbers or
information you wish to enter.
• Numeric is default.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 17
18. Preparing data file in SPSS …
Variable types…
• Numeric.
• A variable whose values are numbers.
• String
• They can contain any characters or Alphanumeric variable.
• They can contain any characters or Alphanumeric variable.
• Values of a string variable are not numeric, and hence not used
in calculations.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 18
19. Preparing data file in SPSS …
Variable Labels
• To assign descriptive variable labels up to 256 characters.
• Can contain spaces that are not allowed in variable names.
Value Labels
• Labels attached to category codes of a variable.
• Labels attached to category codes of a variable.
• Useful if data file uses numeric codes to represent non-numeric categories (for
example, codes of 1 and 2 for male and female).
• The variable defined to be of type as “numeric.” (Handbook of Statistical
analysis using SPSS)
2/14/2021 Prepared by: Dr. Eshetu Ejeta 19
20. Preparing data file in SPSS …
• To Specify Value Labels
• Click the button in the Values cell (…) for the variable that you
want to define.
• For each value, enter the value and a label.
• Click Add to enter the value label.
• Click Add to enter the value label.
• Click OK.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 20
21. Preparing data file in SPSS …
Missing
• Missing value codes.
• SPSS recognizes the period symbol as indicating a missing value.
• If other codes have been used (e.g., 99, 999) these have to be declared to
represent missing values by highlighting the respective cell
• To do this clicking the three-periods symbol and filling in the resulting
Missing Values dialogue box accordingly.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 21
22. Preparing data file in SPSS …
Measure (Nominal, Ordinal and Scale)
• To specify the level of measurement as scale (numeric data on an
interval or ratio scale), ordinal, or nominal.
• A variable can be treated as nominal when its values represent
• A variable can be treated as nominal when its values represent
categories with no intrinsic ranking (for example region and
religious affiliation).
2/14/2021 Prepared by: Dr. Eshetu Ejeta 22
23. Step in Creating a New Data Set in SPSS
• STEP 1: Defining Variables in a New Data Set
• Click on variable view in SPSS
• STEP 2: Entering Data in a New Data Set
• Once all of the variables are defined, enter the data manually using data view
• To indicate a cell that does not have a data value, a period is entered.
• A period represents the system-missing value.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 23
24. Step in Creating a New Data Set in SPSS
• STEP 3: Saving a New Data Set
• Select Save from the File menu. The Save Data As dialog box
opens.
• From the Save as Type drop-down list, select SPSS (*.sav).
• From the Save in drop-down list, select the path where the file will
be saved.
• In the File name box, enter a name for the file. SPSS automatically
adds the extension .sav.
• Click Save
2/14/2021 Prepared by: Dr. Eshetu Ejeta 24
25. Creating a New Data Set From Other File Formats
• SPSS is designed to handle a wide variety of formats including:
• Spreadsheet files created with Excel
• Database files created with dBASE
• Database files created with dBASE
• SPSS data files create on other operating systems.
• E.g. Read the following file, Eye RCT. xlsx, into a SPSS data set
2/14/2021 Prepared by: Dr. Eshetu Ejeta 25
26. Opening an Existing SPSS Data Set
• Select Open from the File menu. This will open the Open File dialog
box
• From the Files of type drop-down list, select .sav.
• From the Look in drop-down list, select the appropriate drive where
the file is located.
• In the File name box, type in the name of the file to be opened.
• Click Open.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 26
27. Modifying Data File in SPSS (use babies.sav)
We can modify data values in data view in many
ways:
• Add and delete cases
• Add and delete variables
• Add and delete variables
• Change data values
• Cut, copy, and paste data values
• Change the order of variables
2/14/2021 Prepared by: Dr. Eshetu Ejeta 27
28. Modifying Data File in SPSS…
To delete a case
• Move down to the case (row) you wish to delete.
• Position your cursor in the shaded section on the left-hand side
that displays the case number.
that displays the case number.
• Click once to highlight the row.
• Press the Delete button on your computer keypad.
• You can also click on the Edit menu and click on Clear
2/14/2021 Prepared by: Dr. Eshetu Ejeta 28
29. Modifying Data File in SPSS…
To delete a variable
• Position your cursor in the shaded section (which contains the
variable name) above the column you wish to delete.
• Click once to highlight the whole column.
• Press the Delete button on your keypad.
• You can also click on the Edit menu and click on Clear.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 29
30. Modifying Data File in SPSS…
To insert a variable between existing variables
• Position your cursor in a cell in the column (variable) to the right of
where you would like the new variable to appear.
• Click on the Edit menu and choose Insert Variable.
• An empty column will appear in which you can enter the data of
the new variable.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 30
31. Modifying Data File in SPSS…
To insert a case between existing cases
• Move your cursor to a cell in the case (row) immediately below
where you would like the new case to appear.
• Click on the Edit menu and choose Insert Case.
• Click on the Edit menu and choose Insert Case.
• An empty row will appear in which you can enter the data of the
new case.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 31
32. Modifying Data File in SPSS…
Sort the data file (Sort cases or sort Variables)
• Will rearrange the rows/column based on a given variable (or variables).
• The values for the selected variables (e.g. gender, bweight) can be sorted in
ascending (smallest to largest, or alphabetical) or descending order.
• Click on the Data menu, choose Sort Cases or variables and specify which
variable will be used to sort by.
• To return file to its original order, repeat the process, asking SPSS to sort the
• To return file to its original order, repeat the process, asking SPSS to sort the
file by ID
2/14/2021 Prepared by: Dr. Eshetu Ejeta 32
34. Modifying Data File in SPSS…
Split the data file (use babies.sav)
• Splits rows into several groups with the effect that subsequent
analyses will be carried out for each group (e.g. males and females)
separately.
• This procedure does not physically alter the file in any permanent
manner.
manner.
• It can be return the data file to its original order (by ID) by using
the Sort Cases
• It has an option you can turn on and off as it suits your purposes.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 34
35. Modifying Data File in SPSS…
To split file
• Click Data > split file > compare groups and specify grouping
variable(sex) > ok
• To see the effect of split file
• Analyze → Descriptive Statistics → Descriptive
• Analyze → Descriptive Statistics → Descriptive
• Highlight Birth weight)
• Click OK
To turn the split option off
• Click Data > Spilt file > Analyze all cases, do not create groups >OK
• Data >Sort Cases> sort by ID >Ok
2/14/2021 Prepared by: Dr. Eshetu Ejeta 35
36. Modifying Data File in SPSS…
Select cases (Use babies.sav)
• A particular subset of the data can be analyzed by selecting specific cases.
Through this, all undesired cases of your data set are either temporarily or
permanently deleted. For example, you may want to analyze only
respondents who are older than 45 years or only males).
2/14/2021 Prepared by: Dr. Eshetu Ejeta 36
37. Select cases…
To turn the select cases option off
Data > Select Cases > All cases > OK
2/14/2021 Prepared by: Dr. Eshetu Ejeta 37
38. Modifying Data File in SPSS…
Merge files
• To merge/combine two or more data files.
• You can merge data from two files in two different ways:
• Merge the active dataset with another open dataset or SPSS Statistics data
• Merge the active dataset with another open dataset or SPSS Statistics data
file containing the same variables but different cases.
• Merge the active dataset with another open dataset or SPSS Statistics data
file containing the same cases but different variables.
• It is used for file handling and file transformations
2/14/2021 Prepared by: Dr. Eshetu Ejeta 38
39. Modifying Data File in SPSS…
Merge files
• From the menus choose:
Data Merge Files Select Add Cases or Add Variables
Add Cases (Use marge1.sav)
Add Cases (Use marge1.sav)
• Add Cases merges the active dataset with a second dataset or external SPSS
Statistics data file that contains the same variables (columns) but different
cases (rows).
2/14/2021 Prepared by: Dr. Eshetu Ejeta 39
40. Data Transformations
Computing Variables (use survey.sav)
• Sometimes we need to compute a new variable based on existing information
(from other variables) in your data. E.g. Use a subject's height and weight to
compute their BMI Or Compute a subscale score from items on a survey
• Compute values for numeric or string (alphanumeric) variables.
• Create new variables or replace the values of existing variables.
• For new variables, we can also specify the variable type and label.
• Compute values selectively for subsets of data based on logical conditions.
• To compute a new variable, click Transform > Compute Variable.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 40
41. Data Transformations…
Compute Variables (click transform > compute variable)
Type the name of a single target variable. It can be an existing variable or a new
variable to be added to the active dataset.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 41
42. Computing a new Variables
2/14/2021 Prepared by: Dr. Eshetu Ejeta 42
43. Example of computing Variable (use survey.sav)
2/14/2021 Prepared by: Dr. Eshetu Ejeta 43
46. Compute Variable: If Cases
• The If Cases dialog box allows you to apply data transformations to
selected subsets of cases, using conditional expressions.
• A conditional expression returns a value of true, false, or missing for
each case.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 46
47. Data Transformations…
Recoding Values
• To transform a variable by grouping its categories or values together
• E.g. to change a continuous variable into a categorical variable, or to merge the categories
of a nominal variable.
• You can recode numeric and string variables.
• Useful for collapsing or combining categories.
• Recode the values within existing variables, or create new variables based on
the recoded values of existing variables.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 47
48. Data Transformations…
Recode into Same Variables
• Allows you to reassign the values of existing variables or collapse
ranges of existing values into new values.
• You cannot recode numeric and string variables together.
• You cannot recode numeric and string variables together.
• From the menus choose:
• Transform > Recode into same Variables...
• Select the variables you want to recode e.g. age.
• Click Old and New Values and specify how to recode values
2/14/2021 Prepared by: Dr. Eshetu Ejeta 48
49. Data Transformations…
Recode into Different Variables
• To reassign the values of existing variables or collapse ranges of
existing values into new values for a new variable.
• For example, collapse Age into a new variable containing age
• For example, collapse Age into a new variable containing age
categories
• You can recode numeric variables into string variables and vice
versa
2/14/2021 Prepared by: Dr. Eshetu Ejeta 49
50. Example of recoding into different variable
(Use survey.sav data)
2/14/2021 Prepared by: Dr. Eshetu Ejeta 50
51. Then Click change click old and new values
2/14/2021 Prepared by: Dr. Eshetu Ejeta 51
54. Screening and cleaning the data
• Before start to analyses the data, it is essential to check the data
set for errors.
• It is very easy to make mistakes when entering data, and
unfortunately some errors can completely mess up your analyses.
• For example, entering 35 when you mean to enter 3 can distort the results
of a correlation analysis.
• So it is important to spend the time checking for mistakes initially,
rather than trying to repair the damage later.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 54
55. Screening and cleaning the data
The data screening process involves a number of steps:
• Step 1: Checking for errors. First, you need to check each of your
variables for scores that are out of range (i.e. not within the range of
possible scores).
• Step 2: Finding the error in the data file. Second, you need to find
• Step 2: Finding the error in the data file. Second, you need to find
where in the data file this error occurred (i.e. which case is involved).
• Step 3: Correcting the error in the data file. Finally, you need to
correct the error in the data file itself.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 55
56. Step 1: Checking for errors
• Use survey.sav data
• When checking for errors you are primarily looking for values that fall
outside the range of possible values for a variable.
• For example, if sex is coded 1=male, 2=female, you should not find
any scores other than 1 or 2 for this variable.
any scores other than 1 or 2 for this variable.
• Scores that fall outside the possible range can distort your statistical
analyses— so it is very important that all these errors are corrected
before you start.
• So you will need to inspect the frequencies for each of your
variables.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 56
57. Checking for categorical variables
1. Checking error for categorical variables
Using Frequencies and check minimum and maximum
2. Checking error for continuous variables
2. Checking error for continuous variables
Using Mean and Standard Deviation
2/14/2021 Prepared by: Dr. Eshetu Ejeta 57
58. Step 2: Finding the error in the data file
2/14/2021 Prepared by: Dr. Eshetu Ejeta 58
59. The column missing during defining variable
• Allows you to define codes that identify a missing value.
• You can have several values allowing you to distinguish between types of
missing data due to the respondent forgetting to answer rather than say not
applicable or refused to answer.
applicable or refused to answer.
• For example, a code of 88 could indicate not applicable, and 99 could
indicate the respondent had missed a question out.
• If a value is defined as a missing value code for a particular variable,
subjects with that code will be dropped from the analysis of that variable.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 59
60. • To set up missing value codes for a variable, click on a cell followed
by the grey square within the Missing column as you did with Type.
• Click Discrete missing values and enter the values to represent
missing in the boxes below (Up to 3 can be entered).
• To complete the entry press OK
2/14/2021 Prepared by: Dr. Eshetu Ejeta 60
61. Video Tutorial
• Setting up a dataset and entering data
• https://www.youtube.com/watch?v=MoKDcPpRa_0
• Frequency Tables & Descriptive Statistics
• https://www.youtube.com/watch?v=XrfQfEwjZA4
• Two-way cross-tabulation with percentages
• Simple Cross tabulation https://www.youtube.com/watch?v=ZOGwysV9ZQY
• Simple Cross tabulation https://www.youtube.com/watch?v=ZOGwysV9ZQY
• Adding percentages - https://www.youtube.com/watch?v=ByluYl5LncQ
• Creating a new variable – log transformion (2min onwards)
• https://www.youtube.com/watch?v=xZCOyQ92X9g
• Recoding a variable
• https://www.youtube.com/watch?v=47GslKRT8Ck
2/14/2021 Prepared by: Dr. Eshetu Ejeta 61
62. • Bar Chart (specifically 3min+)
• https://www.youtube.com/watch?v=0NeaD1Mojp0
• Histogram (specifically 2min 50)=1
• https://www.youtube.com/watch?v=LFGT0WqY5d4
• Scatter Plot with regression line=1
• https://www.youtube.com/watch?v=blfflA-34pQ
• Chi-square test=
• https://www.youtube.com/watch?v=wfIfEWMJY3s
• Independent groups t-test=2
• Independent groups t-test=2
• https://www.youtube.com/watch?v=8alv3kZt8Ug
• Independent groups t-test (Video 2 included model checking)=
• https://www.youtube.com/watch?v=vnQIW5ts3eM
• https://www.youtube.com/watch?v=U2p16pCHW3c 3
• Mann-Whitney U-test
• https://www.youtube.com/watch?v=ALfW6DayQks
• Paired Samples t-test=
• https://www.youtube.com/watch?v=MJGk2sg4EZU
2/14/2021 Prepared by: Dr. Eshetu Ejeta 62
63. • Paired Binary McNemars Test
• https://www.youtube.com/watch?v=3JNGOtKR28I
• Paired Binary McNemars Test
• https://www.youtube.com/watch?v=iZoaXETWAN4
• https://www.youtube.com/watch?v=iZoaXETWAN4
• Kaplan-Meier plot and Log rank test
• https://www.youtube.com/watch?v=Tw1WVxiXHsk
• For a more comprehensive chart for selecting methods see
• www.graphpad.com/www/book/choose.htm.
2/14/2021 Prepared by: Dr. Eshetu Ejeta 63