Return to Bates College Homepage

Tips for Using SPSS Syntax


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

To save your syntax file

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.
 

To run command syntax

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:

  1. Select Help > Topics on the menu bar and the Help Topics window will open.  Click on the Index tab.  Type the analysis you would like to run in the box.  The second box will show possible topics, highlight the desired topic and click on the Display button.
  2. In the Syntax Editor place your cursor on the command (e.g., Frequencies).  On the Syntax Editor toolbar click on the Syntax help button (  ).  The command syntax will now appear for Frequencies.
  3. Select Help > Syntax Guide > Base and Acrobat Adobe will load the SPSS Syntax Guide.  Choose your desired analysis from the menu options in Adobe.
Back to Sample Analyses
 
 
© 2004 Bates College. All rights reserved.
Maintained by Brian Pfohl