
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
- Your syntax file tells you exactly what you've done so far with your data. It holds all details of every step you've taken and the order in which you took them.
- If necessary, you can rerun the exact same steps you took in a matter of seconds, possibly after making some adjustments.
- You hardly need to know any syntax for using it effectively; you can have SPSS generate virtually all of it by using the button from the menu.
- SPSS syntax is very readable and intuitive. You'll naturally understand most of it in no time.
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.
- When you start working on some project, just start SPSS without opening any data.
- Next, simply use the menu as you would with any other software. However, when you want to complete an operation, always click syntax editor window will now automatically pop up, containing the syntax you just generated from the menu. instead of the button. A
- 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.
- Now return to the menu and navigate to the next command you'd like to run. Clicking will -by default- add the syntax for this command to the end of your syntax window.
- Repeat steps 3 and 4 as needed. Like so, you'll build up a complete syntax file entirely from the menu.
- 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 - Next Steps
- Unfortunately, there's no variable view. button for modifying dictionary information. However, this requires just a handful of very simple commands which are discussed in our SPSS Dictionary Tutorials. Do not edit your dictionary manually under
- Even by merely pasting syntax, you'll quickly start recognizing most of the commands you need. At this point, you may gain more speed by typing (instead of pasting) some of your commands. This is because you can dramatically shorten and simplify the syntax pasted by SPSS. For more on this, see SPSS Data Analysis - Basic Roadmap.
THIS TUTORIAL HAS 11 COMMENTS:
By fariba on February 3rd, 2018
Hello there,
l have classified my data and l want to filter 3 of them and do the rest of my analysis based on these three groups, but l don't know which command should l enter in filter tool in order to get what l need. l would appreciate if you help me with that question.
By Melkamu Merid on June 9th, 2018
I want to learn working on SPSS using syntax than just by the drop down menu. I am not able to effectively manage my data using the drop down menu alone. Hence, i want to learn ways that help me communicate with my data in a way that best suits my interest
By Ruben Geert van den Berg on June 10th, 2018
Hi Melkamu!
You're totally right. Besides, your syntax allows you to rerun everything you did in seconds in case you made some mistake. And if you send your syntax and data along with your output and report(s), your clients and supervisors can have faith in your conclusions because they can see what you did.
So: great idea! Keep up the good work!
By Morgan on October 16th, 2019
Very complete guide to syntax! I am impressed reading this article and will try to practice on my blog. Thanks for useful and meaningful articles for me.
By Olympia Joseph on April 15th, 2020
This tutorial has made what sounded and looked like a mountain into a valley. Thanks for sharing, was very helpful indeed.