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

by Karen

Share

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.


Bookmark and Share

{ 3 comments… read them below or add one }

Mark February 6, 2013 at 9:12 am

Many thanks for your blog – very useful.

Reply

Jeromy Anglim November 11, 2009 at 5:00 am

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

Reply

Karen November 11, 2009 at 5:18 pm

Hi Jeromy,

Thanks, I looked at your posts, and I agree, they look very helpful!

Karen

Reply

Leave a Comment

Please note that Karen receives hundreds of comments at The Analysis Factor website each week. Since Karen is also busy teaching workshops, consulting with clients, and running a membership program, she seldom has time to respond to these comments anymore. If you have a question to which you need a timely response, please check out our low-cost monthly membership program, or sign-up for a quick question consultation.

{ 5 trackbacks }

Previous post:

Next post: