By Ruben Geert van den Berg on April 10, 2013 under
Why Use Syntax?.
SPSS Syntax – Six Reasons you Should Use it
Most of us start working with SPSS from its point-click menu. Doing so without pasting and saving all syntax may seem obvious at first but often turns out to be a pitfall. Using SPSS syntax may seem a bit difficult at first but often turns out to save tons of time and effort in the end. This tutorial explains why.
1. Syntax is Ideal Project Documentation
You delivered a report to your client. After a week (or a month or even a year) he calls you and complains that the results just can't be correct
. Suppose you did all your data editing and analyses from syntax
(and saved it). Now you can easily walk through the exact steps you took in the exact correct order and inspect intermediate results extra carefully. If you're really confident about the quality of your work and the data you can even hand over your syntax to your client. The bottom line is that you can retrieve exactly what you did
2. Syntax can be Corrected
Suppose you did a lot of data editing and analyses and you discover some mistake. Perhaps you suddenly realize you forgot to specify some missing values or remove some weird observations from your data. Or maybe your client changes his mind and decides he'd like to see all results for male and female respondents separately. Such cases can often be solved by just adding or modifying a few lines in your syntax and simply rerunning the whole bunch.
3. Syntax can be Recycled
If you're working on a project that has similarities to other projects, chances are you can copy-paste-edit syntax from one to the other. Especially for yearly or quarterly surveys this can be a huge time saver and may enhance the consistency and quality of your work as well. You may also develop your own routines that you'll run over (many) different data sources.
An entirely different example of 'recyclable' syntax are SPSS help forums. Here, experienced users will often happily write some syntax for you if you describe clearly what you'd like to accomplish.
4. Syntax Gets Things Done Fast
Larger or more complex projects may require vast amounts of syntax. Such syntax often has a clear structure. For instance, some task(s) should be repeated a little differently for each variable(s). In such cases, copying-pasting-editing syntax is way faster and more reliable than wasting a day clicking through menu options. However, the real way to tackle such situations is having Python
generate and run the syntax for you.
5. Typing Syntax Saves Time
Changing Value Labels in SPSS - the Wrong Way
A lot of tasks are accomplished fastest
by just typing their syntax in a short form (see SPSS Syntax Shortening
). This goes especially for many dictionary
modifications such as value labels
. However, this doesn't hold for all
commands and may require some practice. Nevertheless, it is by far the preferred way of working for experienced users.
6. Syntax has More Options
This holds especially for transformations
such as DO REPEAT
. Interestingly, these commands are very easy to learn and typically save substantial time and effort while reducing typos. Apart from transformations, some procedures
are also not available from the menu, for example
Using SPSS keywords, especially TO and ALL greatly speeds up a myriad of typical tasks. This tutorial walks you through SPSS main keywords and points out how they can save time and effort. Read more
Some users argue that it's not really necessary to work from syntax. If something goes wrong or a client doesn't believe your results, you can always recover what you did from your journal file. However, the journal file is no reasonable substitute for syntax. This tutorial explains why. Read more