Syntax & Efficient Data Analysis
It’s a good bet that if you’re doing research in an institution such as a hospital that you’re using something like SPSS or Stata to run your stats. These are pretty powerful statistical packages (though, nothing like the amazing “R”) and are fairly user-friendly as they have a decent Graphical User Interface, or “GUI,” that lets users access common statistical functions. Here’s the rub, though: if this is your mode d’emploi, then you’re missing out. Like, really missing out.
SPSS’s real power comes from writing out syntax for your analyses. Doing it this way can be extremely daunting, especially if you’re unfamiliar with programming, but offers many advantages, including:
- Running multiple tests in one pass (or all of them, if you plan well and have some luck to go along)
- Many functions are available through syntax that cannot be accessed directly through the GUI
- Easily change the parameters of an analysis without having to go back through a series of windows and dropdown menus
- You have a record of exactly what you did.
How To Get Started
Ask any programmer how to get started writing code, and they will give you some variation of the following: “Just start programming.” They’re right. There is no replacement for actually doing this sort of thing. That being said, we might be able to get you started in the right direction:
- Pick a test to run. ANOVA, Generalized Linear Model, Least Squares - it doesn’t matter which one - for our purposes they’re all the same
- Set any parameters you wish. Minimally, you should make sure to set enough parameters to make sure the “OK” button is not greyed out (make sure to NOT click “OK”). This tells you that you’ve adequately specified the model. Other than that, there really aren’t any restrictions.
- Lower left hand corner. “Paste” button. Click it. Now.
- If you didn’t already have a syntax editor window open, then SPSS opens one for you and pastes in the syntax for the test you specified.
Bonus round: repeat the above steps with any number of other tests, pasting them into the syntax editor one by one. When you have entered the ones you want, select all and either click on the green triangle/play/run icon, or push
ctrl-r(Windows users) or
- Bonus, bonus round: the SPSS syntax editor (for versions 18 and higher) has one great feature called “code completion,” which does exactly what it says: you start typing code and it helps you complete the line by giving you suggestions.
- Bonus, bonus, bonus round: text editor savvy? Try using it instead of the SPSS syntax editor. As great as code completion is, nothing beats multiple cursors:
- Bonus round: repeat the above steps with any number of other tests, pasting them into the syntax editor one by one. When you have entered the ones you want, select all and either click on the green triangle/play/run icon, or push
This reverse-engineering approach is a great way to gain familiarity with syntax. From here, you can start to experiment with different commands and functions. Also, the Syntax Reference (available from the “Help” menu) is your friend. Your very, very, long and technical friend, to be sure, but a friend nonetheless. Learning to write your tests with syntax will make you a far more efficient and surefooted researcher. It presents with a bit of a learning curve, but is absolutely worth the payoff.