How to Effortlessly Create SPSS Syntax and Automatically Add it to your Output

So hopefully I’ve extolled the benefits of using SPSS Syntax enough that you’re convinced it is something you should regularly use.

Even if you don’t start programming, there are two things you can do to begin learning Syntax and give you the communication and tracking benefits.

1. From now on, when you use menus for an analysis, instead of clicking the “OK” button, click “Paste.”*

When you use the menus and click OK, SPSS is translating your menu choices into syntax.  You just don’t see it.

When you click Paste, though, SPSS opens a syntax window and writes a copy of this syntax.  To run it, simply go to the Syntax window, highlight the procedure you want to run, and click the Run button, which looks like a triangle facing right.

This will get you used to the kind of language SPSS Syntax uses. You can, if you wish, start to edit it.

But even if you don’t, over time you’ll start to notice how logical it is and how the menu choices correspond to phrases in the syntax. And you’ll at least have a record of what you did.

*Alas, the student version of SPSS does not have any syntax capabilities.  This is sad, because I think it’s beneficial to begin using syntax right away.

2. Set up the options to put the syntax in your output as well.

I’ve been using SPSS Syntax, on and off, since 1991.  (And yes, that makes me feel old).  But it was only a few years ago that I realized there is an option to paste a copy of your syntax for each procedure into the Output.  It goes into a Log, which is a text entry right above each procedure.

For the purposes of remembering yourself and communicating to coauthors exactly how you did your analysis (let’s see…did I choose promax or oblimin rotation?), this is the BOMB.  This is more important that running a separate syntax file.  If you are running a lot of analyses and are not impeccably organized about which output goes with which syntax program file, that syntax file isn’t going to help you remember what you did.  It will help you rerun everything quickly to figure out which program gave you that output, but what could be better than having the program, with all the options you chose, right on the output?

Just the other day, after I wrote the post on the importance of using SPSS Syntax to keep track of what the heck you’re doing, a client emailed me with a question about the results of an analysis we’d run in April.  We had run quite a few models to figure out the best-fitting one, and 6 months later, I couldn’t remember which was the final one, so I asked her to send me the final output.

Well, despite the fact that we’d run all the analyses in syntax, she didn’t have this option turned on, so the syntax wasn’t on the output.  It was a head-slapping kind of moment.  (My own, of course).  So I encourage you to turn it on and keep it that way.

It seems that the folks at SPSS also figured out how useful it is, so as of version 15 or 16, it seems to default to this.  At least it did when I installed 16.  But it’s an easy option to change in earlier versions as well.

Go to Edit–>Options, then click on the Viewer tab.  Somewhere in there–it looks a little different in every version–is a little box labeled “Display Commands in Log.”  Click it, and you’re done!

Want to learn more? If you’re just getting started with data analysis in SPSS, or would like a thorough refresher, please join us in our online workshop Introduction to Data Analysis in SPSS.

 

Reader Interactions

Comments

  1. James olvier says

    Hey There,
    I read your blog about SPSS syntax, I think that is the right and relatable thing with SPSS tools. And that blog is also helpful for students who want to perform their data analysis.

  2. Jeromy Anglim says

    I agree. If you are using SPSS, syntax is important for many reasons, not least of which is trying to make your research more reproducible.

    I have a couple of posts on my blog, which might interests readers of this post.

    How to use syntax effectively:
    http://jeromyanglim.blogspot.com/2009/10/introduction-to-spss-syntax-advice-for.html

    How to use syntax to make variable selection more efficient:
    http://jeromyanglim.blogspot.com/2009/10/syntax-tips-for-efficient-variable.html


Leave a Reply

Your email address will not be published. Required fields are marked *

Please note that, due to the large number of comments submitted, any questions on problems related to a personal study/project will not be answered. We suggest joining Statistically Speaking, where you have access to a private forum and more resources 24/7.