SPSS Syntax Beginners Tutorial

SPSS Syntax Window - Example

Most of this tutorial aims at getting you started fast and smoothly with SPSS syntax. But before doing so, let's briefly point out some major reasons why working from syntax is the single best practice for SPSS.For a more elaborate discussion, see SPSS Syntax - Six Reasons you Should Use it.

SPSS Syntax - Some Advantages

SPSS Syntax - Getting Started

Getting started with SPSS syntax is utterly simple. The most basic way for using syntax is described by the steps below.

  1. When you start working on some project, just start SPSS without opening any data.
  2. Next, simply use the menu as you would with any other software. However, when you want to complete an operation, always click Paste instead of the Ok button. A syntax editor window will now automatically pop up, containing the syntax you just generated from the menu.
  3. In order to actually run the syntax, select it with your mouse or a shortkey combination. Pressing ctrl + r will run the syntax you selected. Alternatively, run selected syntax by clicking the green arrow in the toolbar area.
  4. Now return to the menu and navigate to the next command you'd like to run. Clicking Paste will -by default- add the syntax for this command to the end of your syntax window.
  5. Repeat steps 3 and 4 as needed. Like so, you'll build up a complete syntax file entirely from the menu.
  6. When you're done, save the contents of the syntax window as a syntax file and move it to your project folder.

SPSS Syntax - Comments

You can add comments to your syntax files for describing what you're doing and why. Adding comments to syntax it is generally considered excellent practice.
We usually add comments by putting them on a new line, preceding them with an asterisk (*) and ending them with a period (.). This is shown in lines 1 and 2 in the screenshot below.
You can also insert a comment behind a command by adding a slash (/) in front of the asterisk. See line 4 in the screenshot.
When you run lines of syntax containing comments, the latter are ignored by SPSS. Comments are shown in grey in the Syntax Editor window.

SPSS Syntax Comments

SPSS Syntax - Next Steps

Tell us what you think!

*Required field. Your comment will show up after approval from a moderator.