
Many of us have learned to generate SPSS analyses by using the menu selections. However, SPSS also provides command syntax as an alternative way to run your analyses. Although the menu selections are more user friendly for the first time user, command syntax provides the user with greater flexibility. In fact, some commands and options are available only by using the command language. Further, the command language allows you to save your jobs in a syntax file so that you can repeat your analysis at a later date without having to go through all of the menu selections again. Therefore, moving to command syntax is vital to the psychology researcher. The following tips are meant to provide an easy transition from using the menu selections to utilizing the command syntax. These tips and suggestions were compiled from the SPSS help files. Therefore, if you experience any problems with using command syntax refer first to the SPSS help menu.
To open a Syntax Editor window
Syntax windows are text file windows used to enter, edit,
and run commands. To open a Syntax Editor window select File > New >
Syntax in the Data Editor window. A Syntax Editor
window will now appear.
Pasting from a dialog box
While it is possible to open a Syntax Editor window and type in commands, it is easier if you let the software help you build your syntax file by pasting command syntax from dialog boxes. To paste command syntax follow the general procedures for making menu selections for an analysis presented in the Sample Analyses webpage. However, rather than clicking OK to run the analysis instead click on Paste. A Syntax Editor window will appear with the syntax necessary to run the analysis generated by your menu selections.
After the syntax has been pasted into the syntax window,
you can run the pasted syntax, edit
it, and save it in a syntax file (refer below as to
how you can do these tasks).
Simple rules when editing and writing command syntax
For example,
FREQUENCIES
VARIABLES=gender write
/STATISTICS=STDDEV RANGE MINIMUM MAXIMUM MEAN
SKEWNESS SESKEW KURTOSIS SEKURT
/HISTOGRAM NORMAL . - At
the end of the Frequencies command a period appears
T-TEST - The T-test command begins
on a new line
GROUPS=gender(1 2)
/VARIABLES=write.
are both acceptable alternatives that generate the same
results.
For your first save, choose File > Save to open the Save Data As window. Make sure you save to your disk (i.e., the name of your disk should be in the little box at the top of the Save window). Click on Save when you are finished naming your file. Any future saves can now be done by choosing File > Save from the menu bar.
Using a syntax file is very beneficial if you have several
analyses that you want to conduct for a project. By pasting the syntax
after each analysis, you can build a file and save it. You will then
be able to repeat the analysis at a later date. Therefore, if you
discover an error in your data or decide to rerun the analyses on a subset
of your data all you have to do is open the syntax file and run the analyses.
Highlight the commands that you want to run in the Syntax Editor window. Click the Run button (the right-pointing triangle) on the syntax window toolbar.
Or
Select one of the choices from Run on the menu bar in the syntax editor:
Using help in the syntax editor
window
There are three ways to get help with syntax: