You don’t rely on only SPSS menus to run your analysis, right? (Please, please tell me you don’t).
There’s really nothing wrong with using the menus. It’s a great way to get started using SPSS and it saves you the hassle of remembering all that code.
But there are some really, really good reasons to use the syntax as well.
If you’re figuring out the best model and have to refine which predictors to include, running the same descriptive statistics on a bunch of variables, or defining the missing values for all 286 variable in the data set, you’re essentially running the same analysis over and over.
Picking your way through the menus gets old fast. In syntax, you just copy and paste and change or add variables names.
A trick I use is to run through the menus for one variable, paste the code, then add the other 285. You can even copy the names out of the Variable View and paste them into the code. Very easy.
I know that while you’re immersed in your data analysis, you can’t imagine you won’t always remember every step you did.
But you will. And sooner than you think.
Syntax gives you a “paper” trail of what you did, so you don’t have to remember. If you’re in a regulated industry, you know why you need this trail. But anyone who needs to defend their research needs it.
When your advisor, coauthor, colleague, statistical consultant, or Reviewer #2 asks you which options you used in your analysis or exactly how you recoded that variable, you can clearly communicate it by showing the syntax. Much harder to explain with menu options.
When I hold a workshop or run an analysis for a client, I always use syntax. I send it to them to peruse, tweak, adapt, or admire. It’s really the only way for me to show them exactly what I did and how to do it.
If your client, advisor, or colleague doesn’t know how to read the syntax, that’s okay. Because you have a clear answer of what you did, you can explain it.
4. Efficiency again
When the data set gets updated, or a reviewer (or your advisor, coauthor, colleague, or statistical consultant) asks you to add another predictor to a model, it’s a simple matter to edit and rerun a syntax program.
In menus, you have to start all over. Hopefully you’ll remember exactly which options you chose last time and/or exactly how you made every small decision in your data analysis (see #2: Memory).
There are some SPSS options that are available in syntax, but not in the menus.
And others that just aren’t what they seem in the menus.
The menus for the Mixed procedure are about the most unintuitive I’ve ever seen. But the syntax for Mixed is really logical and straightforward. And it’s very much like the GLM syntax (UNIANOVA), so if you’re familiar with GLM, learning Mixed is a simple extension.
Bonus Reason to use SPSS Syntax: Cleanliness
Luckily, SPSS makes it exceedingly easy to create syntax. If you’re more comfortable with menus, run it in menus the first time, then hit PASTE instead of OK. SPSS will automatically create the syntax for you, which you can alter at will. So you don’t have to remember every programming convention.
When refining a model, I often run through menus and paste it. Then I alter the syntax to find the best-fitting model.
At this point, the output is a mess, filled with so many models I can barely keep them straight. Once I’ve figured out the model that fits best, I delete the entire output, then rerun the syntax for only the best model. Nice, clean output.
The Take-away: Reproducibility
What this all really comes down to is your ability to confidently, easily, and accurately reproduce your analysis. When you rely on menus, you are relying on your own memory to reproduce. There are too many decisions, judgments, and too many places to make easy mistakes without noticing it to ever be able to rely totally on your memory.
The tools are there to make this easy. Use them.
Gillian E Mason says
Agree with all of these. An additional beauty of SPSS syntax is being able to add in your comments which adds to the trail of recording decisions you made and why (with dates if you want). Really useful when you look back at your work after months of not using the data!!
William Peck says
Jon K Peck says
You might want to use macros sometimes to refer to groups of variables. You can do this using the macro definition syntax: DEFINE … !ENDDEFINE. Even better, you can use the SPSSINC SELECT VARIABLES (Utilities > Define Variable Macro) extension command to define variable lists using patterns in the names and other metadata such as numeric variables only.
But macros don’t show up in the variable lists in dialog boxes, so you need to use syntax to take advantage of these.
BlueSky Statistics has an almost identical GUI to SPSS but produces syntax in R for easy reproducibility.
R is much more widely used than SPSS syntax
BlueSky is also free while SPSS is not.
Randall Chadwick says
I always tell my clients, code is two things: 1. Documentation, 2. If analyses or anything, for that matter, needs to be run again, it’s highlight and hit run! Also one other thing I do to produce code is write certain syntax in Excel and use things like the “concatenate” function. So variable labels, value labels, etc.
Jon K Peck says
Note that regardless of whether you use the menus (which actually always generate syntax behind the scene) or not, you can always see exactly what you did.
The Notes table for each procedure shows exactly what syntax was used to generate the output.
For data transformations and a few old procedures that don’t generate pivot tables, the log block shows the syntax for whatever code was run even if that was generated from the menus and dialog boxes.
Finally, the journal file shows everything that was run even in previous sessions as long as journaling and append options are turned on. And those are on by default. You can find the journal by looking at Edit > Options > File Locations. You can reexecute the code in the journal or just pick out the parts you need.
William Peck says
very good, Jon!
Patrick Koomson says
i run the command “freq all” in syntax.