SPSS Basics: Getting Started with Syntax

Getting started is half the battle, especially when trying to learn a new software program or trying to accomplish a new task in a familiar one. In a previous post, I discussed some of the advantages of using syntax in SPSS instead of the software program's drop-down menus. As an astute reader commented, syntax can be very frustrating because it requires the user to follow its specifications very closely. That means that any misplaced characters or punctuation can prevent your program from running correctly, or from running at all. So is SPSS syntax worth learning for garden-variety social scientists studying organizational behavior, industrial and organizational psychology, and other related fields? Absolutely. But that's because I'm going to try to demonstrate how you can use SPSS syntax in a smart, efficient way to do the basic tasks that you may encounter on a relatively frequent basis in graduate school classes, research projects, and in providing consulting recommendations.

I'll do that through posting actual syntax code that you can copy, paste, edit, and run on your own data. That should help with tasks including computing and recoding variables, calculating descriptive statistics, and conducting analyses such as reliability analysis, factor analysis, correlations, and hierarchical regression--including mediation and moderation analyses. I'll also post some of the tips that I've learned the hard way regarding keeping your syntax and data files user-friendly.

To get started, however, I'm going to assume that you've never used syntax before. You may even be a little scared of it. You're studying or previously studied psychology, organizational behavior, or human resource management because you want to help people and organizations work and play well with one another.

No one told you'd have to be a statistician or computer scientist. But neither am I. All I'm saying is that good consulting and good science builds from an understanding of research methods; therefore, it makes good sense to figure out how to use the tools we have available in the smartest, most efficient way possible. Statisticians, computer scientists, and actuaries: You may want to search elsewhere for solutions to your specific challenges.

SPSS File Types

SPSS has three common file types associated with it. First, there's your data file. This file ends with the file extension .sav. Second, there's your output file. This file ends with the file extension .spo, and SPSS automatically creates it when your run an analysis. Third, there's your syntax file. This file ends with the file extension .sps.

Creating a New Syntax File

To create a syntax file, start by opening the SPSS program or a data set (.sav file). Then, go to the drop-down menu at the top of the screen, go to "file," then "new," and select "syntax file." A new screen should open that looks like the image below. Note that an empty data set is in the background, and the new syntax file is in the foreground.

The syntax file in the foreground serves as your "command center," so to speak, for your data analysis. I recommend maintaining a single syntax file for each project. For example, I used the same single syntax file for all of the analysis relevant to my master's thesis and have separate ones for other projects. Basically, the syntax file is a text document that you can save, "save as," copy and paste items into and from, and so on.

Helpful hint: If you're ever on a computer that doesn't have SPSS yet need to open your syntax file for some reason, you can open it as a text file in Notepad or Wordpad. You won't be able to run the program, but you'll be able to see it, read the notes you made in it, and copy its contents.

So now you know (a) what a syntax file looks like and (b) how to create a new one. Future posts will address next steps and general tips for using the file to analyze your data. Congratulations--you got started, and that's half the battle.