Experiment 4
Experiment 4
1. Sorting file
2. Split file
3. Compute
4. Recode
5. Select case
AIM of the Experiment: The aim of the Experiment is to implement various functions in SPSS.
Objective:
1. Get a good Understanding of basic to intermediate to advanced features of SPSS.
2. Understand the context in which each of the statistics tools need to be used
3. Get a hold on Built-in techniques to prepare data for analysis quickly and easily.
Input/Apparatus Used:
Statistical Package for Social Science (SPSS) Software by IBM
Course Outcome:
1. Sorting data allows us to re-organize the data in ascending or descending order with respect
to a specific variable.
2. Student will learn how to sorting a file.
3. Students will learn how to perform select cases function.
SORTING FILE
Sorting data allows us to re-organize the data in ascending or descending order with respect
to a specific variable. Same procedures in SPSS require that your data be sorted in a certain
way before the procedure will execute. Using SPSS and Pasw/sorting variables.
One of the function you will often want to perform in the data view of the data editor is
sorting by a variables values to bring those of similar value together. This can be a very useful
when exploring the raw data in your datasheet. There are two ways to do this. One is quite
simple, the other allows sorting on more than one variable.
STEPS
The simple way to sort variable values is to make sure you are looking at the data view tab.
Then scroll to the variable by which you want to sort. Right click on its column heading and a
context menu will appear. At the bottom of the context menu are two sorting options: “ sort
ascending” and “sort descending”. Choosing the first will move the smallest values to the top
of the data set while a descending sort will bring up the largest value. Keep in mind that SPSS
automatically (unlike excel) moves all rows in unison. So you don’t need to worry about cases
becoming misaligned when sorting.
Sometimes its useful to sort on multiple variables, which means that SPSS while sort the data
set by the values of the first variable than breaks ties in that sort by sorting on the values of
the second variable and so on. The sort on multiple variable at once choose “ data” >”sort
cases” :
You will get dialog window:
The “sort order” box allows the choice between ascending or descending order once again.
On the left is a list of all the variables in the data set. Choose them the most important sort
first by clicking the variable involved and then the blue arrow and repeat.
Save your data set after sorting to retain it as a default sorting.
SPLIT FILE
Split file is a SPSS facility to perform any analysis sequence for each group defined by a categorical
split variables. When you turn split file on. It will be active until you turn it off explicity or you replace
the current data set with a different one.
STEPS
The data>split file dialog lets you control this mechanism. To active
6. Choose either
7. Compare groups: produces single tables including all groups
8. Organize output by groups: produces separate tables for each group
9. Select a variable region in our example for the group based on field
10. Make sure to check sort the file by grouping variables is selected, if you are not certain that
the file is sorted on the grouping variable.
After clicking OK, split is activated ( you can see “split file on” in the status line of the SPSS window)
and any procedure you invoke now will be performed. Separately on each group defined by the
grouping variables as long as you do not turn off split file.
If you need to know what is current split variable you will have to open the data> split file
dialog.
COMPUTE
Sometimes you may need to compute a new variable based on existing information (from
other variables) in your data.
For example: you may want to:
• Convert the units of a variable from feet to meters.
• Use a subjects height and weight to compute their BMI.
• Compute a sub scale score from items on a survey
• Apply a competition conditionally so that a new variable is only computed for cases where
certain conditions are meet
In this tutorial we will discus how to compute variables in SPSS using numeric expressions, built –in
functions and conditional logic.
To compute a new variable. Click transform > compute variable
The compute variable window will open where you specify how to calculate your new variable
RECODE
Sometimes you will want to transform a variable by grouping its categories or values
together. For example: you may want to change a continuous variable into a categorical variable or
you may want to merge the categories of a normal variable. In SPSS this type of transform is called
recoding.
In SPSS there are three basic options for recoding variables.
• Recode in different variables
• Recode into same variables
• Do if syntax
Recoding into a different variable transforms an original variable into a new variable. That is the
changes do not overwrite the original variable, they are instead applied to a copy of the original
variable under a new name.
STEPS
To recode into different variables click transform >recode into different variables
The recode into different variables window will appear. The left column lists all of the variables in your
data set. Select the variables you wish to recode by clicking it. Click the arrow in the center to move
the selected variable to the center text box.
SELECT CASES
Data files are not always organized to meet specific users need. For example: users may wish
to select specific subjects or split the data file into separate groups for analysis. If you have two or
more subjects groups in your data and you want to analyze each subject independently you want to
analyze each subject you can use the select case option.
STEPS
3. Open the part1.sav data file provided in your computer. Make sure you are on data view
4. Click the data menu, and then click select cases. The select cases dialog box opens. Select the
if condition is satisfied option
5. Click the if button. The select cases: if dialog box opens. Select the gender variables in the left
box, and then click the transfer arrow button to move it to the right box. Click the = button
and then click the 1 button. Because the symbol 1 represents formals according to our value
levels we are telling SPSS to select only female participants.
6. Click the continue button to return to the select cases dialog box. Click the OK button to return
to the data view. All males will be excluded from the statistical analysis.
7. Run an analysis. Note the crossed out participants in the data file. Those represents all the
male participants.
8. To undo the select cases open the select cases box and click the reset button.
Discussion:
(i) Discuss the usage of implementing various functions such as Sorting, Splitting, Select cases,
Compute, Recode in SPSS