SPSS Syntax Part 1: Breadcrumbs
SPSS is commonly used, at least within psychology, for doing statistical analyses. Many people prefer using SPSS because it has menus that allow for point-and-click running of analyses as opposed to writing syntax. Yet SPSS supports syntax, and it can be incredibly useful. Here, I want to present the first of two ways that I predominantly use SPSS syntax: saving a series of breadcrumbs.
Working on a project that spans across more than one session (even if it's only a few days) is much easier when syntax is used to save a history of which analyses were conducted. Doing so allows for easily re-running analyses, and it prevents you from accidentally re-doing analyses that are unnecessary.
To start, you can go to File > New > Syntax to open a new syntax file. With the new syntax window open, use point-and-click to setup any type of analysis (which you can do from the database window, or the syntax's window). Once everything is setup, then don't press the OK button, but instead press Paste. Once you do, the window for setting up the analysis will close, and you'll see syntax pasted into your syntax window. The syntax that's there is all set up to run the analysis you just chose, with all of the options you selected. Take a look and try to familiarize yourself with the different components.
For running analyses, I don't recommend writing syntax from scratch; instead, I recommend using point-and-click then pasting the syntax. SPSS syntax is quirky, so it's usually faster to do it that way for analyses. But the point of doing this isn't to write the syntax for analyses from scratch anyway, it's to have a saved history of analyses that have already been done.
To actually run the analysis, select all of the syntax that was pasted then click the green arrow (looks like a play symbol) at the top of the window. At any time, you can select whatever syntax you want to run followed by clicking that green arrow; you don't have to run all of the syntax at once.
After that, you should see your results! But what if you need to remember the results? It's a pain to go through and re-run analyses every time, try to scroll around the output window to find the values you need, and so on. Thankfully, you don't need to do that.
SPSS syntax (and generally all syntax) supports comments. Comments allow you to make notes in the syntax that are helpful for you, but will be ignored by SPSS. To make any text into a comment, just start the line with an asterisk (*) and end it with a period. That way you can run an analysis, look at the relevant output, and make a comment with the important information right above the syntax for that analysis. Next time you go to work with SPSS, you can open up your syntax file and quickly review everything you've done that's relevant!
Here's an example from one of my syntax files:
*BMIz sig corr with family meals. PARTIAL CORR /VARIABLES=BMI_zscore avgSed depMood fhrb1 BY age /SIGNIFICANCE=TWOTAIL /MISSING=LISTWISE.
Here, "*BMIz sig corr with family meals." is a comment to remind me that the frequency of family meals was significantly correlated with BMIz scores. "PARTIAL CORR" is the type of analysis that was conducted (a partial correlation), and the rest of the lines represent the different pieces of information SPSS needs for running the analysis. By default SPSS capitalizes words that mean something to it (as opposed to variable names); this is a standard, and it's recommended that you do the same with syntax you write just so things are consistent and easier for others to understand.
The other primary use for SPSS syntax is the computation of variables, which I will discuss in another post.