SPSS Syntax instructions.

advertisement
TechSociety Research
SPSS Syntax
Compiled by Leora Lawton, TechSociety Research
(Updated March 3, 2009)
Note: make sure to save frequently.
1. What is Syntax?
Remember: An SPSS data file has a .sav extension.
An SPSS output file has a .spo extension.
An SPSS syntax file has a .sps extension. (syntax is the programming
commands).
You can use SPSS in Graphical User Interface (GUI) which means just using
your mouse to do the work. Or you can write syntax programming language.
Whereas we started with GUI we will now show how to do these analyses in
syntax.
2. Getting started in syntax.
The easiest way to see how to do something in syntax is first to set it up in GUI
and then select Paste. Here’s how one would do frequencies of a variable.
1. Analyze-Descriptive statistics-Frequencies
2. Select a variable.
3. Now, instead of clicking on OK, click on Paste.
4. A syntax window (with the .sps extension) will open up, and you will have
something like this:
FREQUENCIES
VARIABLES=q1
/ORDER= ANALYSIS .
Note that there is a period (.) at the end of the final command. There has to be a
period at the very end of the procedure. “Frequencies” is the statistical
procedure, ‘Variables =” is the list of variables that you want to run frequencies
on (in this case, educ), and /ORDER is an option. All options are preceded with
a slash /.
Now try this with adding on a statistics option, mean. You’ll get this:
FREQUENCIES
VARIABLES=q1
/STATISTICS=MEAN
/ORDER= ANALYSIS .
Note that the statistics for mean option is has a slash.
© 2008 Leora Lawton
1
TechSociety Research
So starting with GUI will show you the format in case you forget or don’t know.
But once you know how to write syntax, and you are doing something repeatedly,
then it’s better to know syntax because (a) it saves time; (b) you document what
you’ve done by saving the syntax file; and (c) it reduces error since you can more
easily repeat what you’ve done elsewhere and previously in a research project.
2. Running the commands in syntax instead of GUI.
Okay, you’ve now seen how it works using one variable. Now let’s try it with
another variable, but this time, straight from the syntax window.
In the syntax window, instead of the variable you used, q1, now choose two other
variables from the list in the Variables window (e.g., q2). Type their names in
instead of EDUC in the Variables= line.
If this is the only command on the syntax window, then go to RUN-ALL
If there are other commands, then highlight the commands (from
FREQUENCIES through ANALYSIS.) and then RUN-SELECTION.
Exercises:
1. Develop and present syntax for Frequencies with Median (hint: you’ll need a
numeric – not categorical – variable for this).
2. Develop and present syntax for Crosstabs between two variables. Include
Observed, Row and Column in the cells option. This time use categorical
variables.
3. Save the syntax file into your own directory.
4. Print the syntax file and turn it in next week.
© 2008 Leora Lawton
2
Download