Step IISyntexSPSS
Step IISyntexSPSS
Step IISyntexSPSS
Step-by-Step
Abdelkamel ALJ
Dpartement de Mathmatiques, Universit Libre de Bruxelles
ALJ (ULB)
UALS 2009
1 / 43
Outline of step II
1
Introduction
ALJ (ULB)
UALS 2009
2 / 43
Outline of step II
1
Introduction
ALJ (ULB)
UALS 2009
2 / 43
Outline of step II
1
Introduction
ALJ (ULB)
UALS 2009
2 / 43
Introduction
The aim of this seminar is to help you learn about the use of SPSS syntax as an alternative
to the point-and-click interface.
ALJ (ULB)
UALS 2009
3 / 43
Introduction
The aim of this seminar is to help you learn about the use of SPSS syntax as an alternative
to the point-and-click interface.
The use of syntax is also helpful in documenting your analysis.
ALJ (ULB)
UALS 2009
3 / 43
Introduction
The aim of this seminar is to help you learn about the use of SPSS syntax as an alternative
to the point-and-click interface.
The use of syntax is also helpful in documenting your analysis.
ALJ (ULB)
UALS 2009
3 / 43
Introduction
The aim of this seminar is to help you learn about the use of SPSS syntax as an alternative
to the point-and-click interface.
The use of syntax is also helpful in documenting your analysis.
ALJ (ULB)
UALS 2009
3 / 43
Introduction
The aim of this seminar is to help you learn about the use of SPSS syntax as an alternative
to the point-and-click interface.
The use of syntax is also helpful in documenting your analysis.
A syntax file is nothing more than a text file ; hence, you can type code and comments into
it, and you can cut-and-paste in it as you would in any text editor. To run the code that you
have pasted, you simply highlight it and click on the right-pointing arrow at the top.
The journal is a log of all of the SPSS commands that have been issued, but with no output.
ALJ (ULB)
UALS 2009
3 / 43
Introduction
The aim of this seminar is to help you learn about the use of SPSS syntax as an alternative
to the point-and-click interface.
The use of syntax is also helpful in documenting your analysis.
A syntax file is nothing more than a text file ; hence, you can type code and comments into
it, and you can cut-and-paste in it as you would in any text editor. To run the code that you
have pasted, you simply highlight it and click on the right-pointing arrow at the top.
The journal is a log of all of the SPSS commands that have been issued, but with no output.
One of the most important things to remember when writing SPSS syntax is that all
commands must end in a period (.).
To start a comment, use either an asterisk (*) or the command comment.
ALJ (ULB)
UALS 2009
3 / 43
Importing data
Outline
Introduction
ALJ (ULB)
UALS 2009
4 / 43
Importing data
Importing data
The SPSS command for opening a data file is get file followed by the path where the file is located.
ALJ (ULB)
UALS 2009
5 / 43
Importing data
Importing data
The SPSS command for opening a data file is get file followed by the path where the file is located.
Dont forget to include the file extension.
ALJ (ULB)
UALS 2009
5 / 43
Importing data
Importing data
The SPSS command for opening a data file is get file followed by the path where the file is located.
Dont forget to include the file extension.
ALJ (ULB)
UALS 2009
5 / 43
Importing data
Importing data
The SPSS command for opening a data file is get file followed by the path where the file is located.
Dont forget to include the file extension.
ALJ (ULB)
UALS 2009
5 / 43
Importing data
Importing data
The SPSS command for opening a data file is get file followed by the path where the file is located.
Dont forget to include the file extension.
ALJ (ULB)
UALS 2009
5 / 43
Importing data
Importing data
The SPSS command for opening a data file is get file followed by the path where the file is located.
Dont forget to include the file extension.
ALJ (ULB)
UALS 2009
5 / 43
Outline
Introduction
ALJ (ULB)
UALS 2009
6 / 43
Two commands that you can use to create numeric variables are compute and if.
ALJ (ULB)
UALS 2009
7 / 43
Two commands that you can use to create numeric variables are compute and if.
There is no then in SPSS
ALJ (ULB)
UALS 2009
7 / 43
Two commands that you can use to create numeric variables are compute and if.
There is no then in SPSS
ALJ (ULB)
UALS 2009
7 / 43
Two commands that you can use to create numeric variables are compute and if.
There is no then in SPSS
ALJ (ULB)
UALS 2009
7 / 43
Two commands that you can use to create numeric variables are compute and if.
There is no then in SPSS
ALJ (ULB)
UALS 2009
7 / 43
Two commands that you can use to create numeric variables are compute and if.
There is no then in SPSS
ALJ (ULB)
UALS 2009
7 / 43
ALJ (ULB)
UALS 2009
8 / 43
ALJ (ULB)
UALS 2009
8 / 43
Outline
Introduction
ALJ (ULB)
UALS 2009
9 / 43
ALJ (ULB)
UALS 2009
10 / 43
ALJ (ULB)
UALS 2009
10 / 43
ALJ (ULB)
UALS 2009
10 / 43
ALJ (ULB)
UALS 2009
11 / 43
ALJ (ULB)
UALS 2009
11 / 43
Outline
Introduction
ALJ (ULB)
UALS 2009
12 / 43
ALJ (ULB)
UALS 2009
13 / 43
ALJ (ULB)
UALS 2009
13 / 43
ALJ (ULB)
UALS 2009
13 / 43
ALJ (ULB)
UALS 2009
14 / 43
ALJ (ULB)
UALS 2009
14 / 43
Dates
Outline
Introduction
ALJ (ULB)
UALS 2009
15 / 43
Dates
Dates
ALJ (ULB)
UALS 2009
16 / 43
Dates
Dates
ALJ (ULB)
UALS 2009
16 / 43
Dates
Dates
ALJ (ULB)
UALS 2009
17 / 43
Dates
Dates
ALJ (ULB)
UALS 2009
17 / 43
Dates
Dates
ALJ (ULB)
UALS 2009
18 / 43
Dates
Dates
ALJ (ULB)
UALS 2009
18 / 43
Missing data
Outline
Introduction
ALJ (ULB)
UALS 2009
19 / 43
Missing data
Missing data
There are two different types of missing data in SPSS :
system-missing : is displayed as a dot (.) in the column of a numerical variable.
ALJ (ULB)
UALS 2009
20 / 43
Missing data
Missing data
There are two different types of missing data in SPSS :
system-missing : is displayed as a dot (.) in the column of a numerical variable.
user-defined missing : you can define your own missing values.
ALJ (ULB)
UALS 2009
20 / 43
Missing data
Missing data
There are two different types of missing data in SPSS :
system-missing : is displayed as a dot (.) in the column of a numerical variable.
user-defined missing : you can define your own missing values.
ALJ (ULB)
UALS 2009
20 / 43
Missing data
Missing data
There are two different types of missing data in SPSS :
system-missing : is displayed as a dot (.) in the column of a numerical variable.
user-defined missing : you can define your own missing values.
ALJ (ULB)
UALS 2009
20 / 43
Missing data
ALJ (ULB)
UALS 2009
21 / 43
Missing data
ALJ (ULB)
UALS 2009
21 / 43
Missing data
ALJ (ULB)
UALS 2009
21 / 43
Missing data
ALJ (ULB)
UALS 2009
21 / 43
Missing data
ALJ (ULB)
UALS 2009
21 / 43
Missing data
ALJ (ULB)
UALS 2009
21 / 43
subsetting data
Outline
Introduction
ALJ (ULB)
UALS 2009
22 / 43
subsetting data
You can create variables to use as filter variables and keep them in your data set.
ALJ (ULB)
UALS 2009
23 / 43
subsetting data
You can create variables to use as filter variables and keep them in your data set.
It is important to note that SPSS does not treat system-missing and user-defined missing values the
same way.
ALJ (ULB)
UALS 2009
23 / 43
subsetting data
You can create variables to use as filter variables and keep them in your data set.
It is important to note that SPSS does not treat system-missing and user-defined missing values the
same way.
ALJ (ULB)
UALS 2009
23 / 43
subsetting data
You can create variables to use as filter variables and keep them in your data set.
It is important to note that SPSS does not treat system-missing and user-defined missing values the
same way.
ALJ (ULB)
UALS 2009
23 / 43
subsetting data
You can create variables to use as filter variables and keep them in your data set.
It is important to note that SPSS does not treat system-missing and user-defined missing values the
same way.
ALJ (ULB)
UALS 2009
23 / 43
Outline
Introduction
ALJ (ULB)
UALS 2009
24 / 43
ALJ (ULB)
UALS 2009
25 / 43
ALJ (ULB)
UALS 2009
25 / 43
ALJ (ULB)
UALS 2009
26 / 43
ALJ (ULB)
UALS 2009
26 / 43
ALJ (ULB)
UALS 2009
27 / 43
ALJ (ULB)
UALS 2009
27 / 43
ALJ (ULB)
UALS 2009
28 / 43
Outline
Introduction
ALJ (ULB)
UALS 2009
29 / 43
Examples
ALJ (ULB)
UALS 2009
30 / 43
Examples
ALJ (ULB)
UALS 2009
30 / 43
Examples
ALJ (ULB)
UALS 2009
30 / 43
Examples
ALJ (ULB)
UALS 2009
31 / 43
Examples
ALJ (ULB)
UALS 2009
31 / 43
Outline
Introduction
ALJ (ULB)
UALS 2009
32 / 43
One-to-one merge
ALJ (ULB)
UALS 2009
33 / 43
One-to-one merge
ALJ (ULB)
UALS 2009
33 / 43
One-to-one merge
Use SORT CASES to sort dads on famid and save that file(we will call it dads2.sav)
ALJ (ULB)
UALS 2009
33 / 43
One-to-one merge
1
2
Use SORT CASES to sort dads on famid and save that file(we will call it dads2.sav)
Use SORT CASES to sort faminc on famid and save that file(we will call it faminc2.sav)
ALJ (ULB)
UALS 2009
33 / 43
One-to-one merge
1
2
3
Use SORT CASES to sort dads on famid and save that file(we will call it dads2.sav)
Use SORT CASES to sort faminc on famid and save that file(we will call it faminc2.sav)
Use MATCH FILES to merge the dads2.sav and faminc2.sav files based on famid
ALJ (ULB)
UALS 2009
33 / 43
One-to-one merge
ALJ (ULB)
UALS 2009
34 / 43
One-to-one merge
ALJ (ULB)
UALS 2009
34 / 43
One-to-many merge
ALJ (ULB)
UALS 2009
35 / 43
One-to-many merge
ALJ (ULB)
UALS 2009
35 / 43
One-to-many merge
Use SORT CASES BY to sort dads on famid and save that file (we will call it dads2)
ALJ (ULB)
UALS 2009
35 / 43
One-to-many merge
1
2
Use SORT CASES BY to sort dads on famid and save that file (we will call it dads2)
Use SORT CASES BY to sort kids on famid and save that file (we will call it kids2)
ALJ (ULB)
UALS 2009
35 / 43
One-to-many merge
1
2
3
Use SORT CASES BY to sort dads on famid and save that file (we will call it dads2)
Use SORT CASES BY to sort kids on famid and save that file (we will call it kids2)
Use MATCH FILES to merge the dads2 and kids2 files. However, since the dads file is the
file with one observation, use /TABLE="dads2.sav", not /FILE="dads2.sav" to specify the
dads file.
ALJ (ULB)
UALS 2009
35 / 43
One-to-many merge
ALJ (ULB)
UALS 2009
36 / 43
One-to-many merge
ALJ (ULB)
UALS 2009
36 / 43
Random Numbers
Outline
Introduction
ALJ (ULB)
UALS 2009
37 / 43
Random Numbers
ALJ (ULB)
UALS 2009
38 / 43
Random Numbers
SPSS syntax
SET SEED=2000000
ALJ (ULB)
UALS 2009
38 / 43
SPSS syntax
Outline
Introduction
ALJ (ULB)
UALS 2009
39 / 43
SPSS syntax
Example
Create 1000 cases
Return normally distributed values with a mean of 100 and a standard deviation of 20.
Return Poisson distributed values with a mean of 10.
ALJ (ULB)
UALS 2009
40 / 43
SPSS syntax
Example
Create 1000 cases
Return normally distributed values with a mean of 100 and a standard deviation of 20.
Return Poisson distributed values with a mean of 10.
ALJ (ULB)
UALS 2009
40 / 43
SPSS syntax
Example
Create 1000 cases
Return normally distributed values with a mean of 100 and a standard deviation of 20.
Return Poisson distributed values with a mean of 10.
ALJ (ULB)
UALS 2009
40 / 43
SPSS syntax
Example
Create 1000 cases
Return normally distributed values with a mean of 100 and a standard deviation of 20.
Return Poisson distributed values with a mean of 10.
ALJ (ULB)
UALS 2009
40 / 43
SPSS syntax
Histograms
ALJ (ULB)
UALS 2009
41 / 43
SPSS syntax
Histograms
ALJ (ULB)
UALS 2009
41 / 43
SPSS syntax
ALJ (ULB)
UALS 2009
42 / 43
SPSS syntax
ALJ (ULB)
UALS 2009
42 / 43
SPSS syntax
ALJ (ULB)
UALS 2009
42 / 43
SPSS syntax
suivre...
ALJ (ULB)
UALS 2009
43 / 43