This chapter will help you to:
SPSS has a storied past. It is not a story that is very interesting and we will not spend time on it here. Instead, we’ll fast-forward to 2020. SPSS stands for “Statistical Package for the Social Sciences” and it is owned by IBM. It is widely used in the social sciences (e.g., psychology, sociology, economics, etc.) in part because of its ability to do many analyses but more because of the ease of use. One can perform most analyses in SPSS without needing to do any coding but SPSS has the flexibility to do much more through its syntax.
The program uses three windows.
The data editor window (see Figure 2.1) looks like a spreadsheet (e.g., Microsoft Excel or Google Sheets) but it is not. Whereas spreadsheets have the ability to do calculations in a cell, the data editor can only hold values.
Figure 2.1
The Data Editor Window
The Data Editor Window consists of two tabbed views (see the bottom-left corner of Figure 2.1). The first is the data view, which holds the actual values. The second is the variable view, which contains the properties for each variable. Although the data view is the one you see initially when opening a file, I think it is best if we start with the variable view.
Figure 2.2
The Variable View of the Data Editor Window
The variable view tab (pictured in Figure 2.2) is where you’ll want to tell SPSS about the variables in your data set. This is important because the guesses that SPSS makes about your variables can be wrong. If your variable properties are not set correctly, SPSS may block you from running a procedure or it may misrepresent the output. ALWAYS CHECK THE VARIABLE VIEW. Really, ALWAYS.
The variable view seems to have a similar layout to the data view (i.e., cells from the intersection of rows and columns) but the major difference lies in what goes in each cell.
Each row represents one variable and the columns hold the values for the various properties for the variable. Those properties include:
Name: This is a special, shortened version of what you call your variable. SPSS does not like spaces or special characters (e.g., $ / or .). You can use underscores (i.e., _)
Type: The sets the kind and format of data for the variable. Unless it is something that you will not analyze, it should be “numeric”. If it has a special formatting like money (e.g., starts with “$”) or is in scientific notation (e.g., “10E4”), you can specify that. To change the type, click on the cell under the “Type” in the row for the variable you want to change. Click on the blue button with three dots (“…”) and a pop-up will open (see Figure 2.3).
Figure 2.3
Variable Type Pop-Up
We’ll cover the special case of variables that contain words rather than numbers. Although SPSS will let you type in letters, you won’t be able to do much with them. Rather than have a “string” variable, we’ll want to dummy code that variable into a numeric variable.
Width: This is how many characters you want to reserve to display values in the data editor. This is an old property that was used to allocate memory for variables back in the old days of computers when memory was a very limited resource. You won’t need to change this. SPSS will adjust it if needed.
Decimals: This one you will want to change. The default is to display two digits past zero, even if you only have whole numbers. If you will not have decimals, change this to 0. This is really important for dummy coding.
Label: Remember the special shortened variable name? It doesn’t look very good. Update the label column to how you want the variable name to appear when it is printed in the output (e.g., in a table or graph). It can contain special characters and spaces.
Values: Values are used to associate text labels with numeric values. This is what we’ll use for dummy coding. Stay tuned for details but this basically allows us to show “Male” anytime the value for “Gender” is set to 0, for example.
Missing: There are often gaps in our data sets. Someone may have not responded, there may have been a recording issue, or we may not be able to read the response. Whatever the reason, you should specifiy, explicitly, when a value for a variable is missing. Open the pop-up dialogue box to select “Discrete missing values” and enter values that signify missing (see Figure 2.4). I suggest using outlandish values that are not possible for your variable. For example, “275” is not possible for number of children.
Figure 2.4
Missing Values Pop-Up
Columns: This is another holdover from days-gone-by. It specifies how wide the variable column should appear in the data view. I suggest you just change the width by dragging the column wider or more narrow in the data view.
Align: The default is for the values to align to the right of the cell in the data view but you can choose “left” or “center,” if you wish.
Measure: This one is important! SPSS has some baked-in rules about which graphs and analyses are appropriate for different scales of measurement. Furthermore, SPSS will guess the scale of measurement but it is often wrong or at least overly strict with rules. It is best if you think about your data and the analyses you want to perform befores setting your analyses. Just a hint: set numeric variables as “scale” if you want to caluclate means or anything that relies on means. In SPSS lingo, scale = “interval” or “ratio” scales.
Role: The role property is outside of the scope of this class as it is used in modeling aspects of SPSS which we will not cover. You can leave this property as is.
Remember, ALWAYS CHECK THE VARIABLE VIEW. With the variable properties set for our variables, we can input data through the data view tab.
As mentioned before, although the data view looks like a spreadsheet, it is not. It simply a way to hold the values of different variables for different “entities”. By entities, I mean that from which you got the data (was that even intelligible?). In psychology, we often record data from a person. We could also have data about a group or a state, etc.
Any data that came from that enttity will be put in a single row with each cell corresponding to a different variable. If you have variable set up, you should see the variable names as the column headers. The columns for which no variable is set will appear as a grayed-out “var.”
By the way, this “wide” format for data entry is required by SPSS but can cause some difficulties later for repeated-measures analyses. There are work-arounds but it isn’t perfect.
The only tricky bit with the data view involves those dummy coded values. If you have dummy codes (i.e., numbers that represent text values), you can see the text instead of the numbers by clicking the “Value Labels” button in the toolbar (see Figure 2.5).
Figure 2.5
Value Labels Button in Toolbar
We’ll next take a quick look at the syntax editor window.
A long, long time ago, before many of my student were born, SPSS and all computer programs did not have a “point-and-click” interface. Rather, one had to type in commands nto a console. That may sound terrifying at worst and inconvenient at best but you won’t need to worry too much about this archaic world of code. You won’t need to worry but you will need to see it and use it.
Figure 2.6
The Syntax Editor Window
The syntax editor (see Figure 2.6) has two part. The main part, on the right, is where you enter the syntax (i.e., code). It is like a souped-up text editor because of a few useful features. As you type keywords, it will offer suggestions to complete the keyword. It also changes the color of text depending on the role of the word you type (e.g., command, option, variable, etc.).
Although I won’t ask you to write but more than a few lines of syntax, it is helpful to pay attention to the syntax and to use it to your advantage. You should utilize syntax to
SPSS makes generating syntax really easy. Before you finish a procedure using the point-and-click interface, you can click the “paste” button in the bottom of the window. The associated syntax is then inserted at the end of your syntax file. You can then add comments or change the syntax as you’d like. You can also copy and paste syntax within the editor. This is a time saver when you want to re-run an analysis but with a different variable, for example.
To run syntax from the editor, highlight the syntax by clicking and dragging across the section you want then click the big green “play” button in the toolbar.
To insert a comment, star the line with an asterisk (*) and end it with a period (.). That period is a crucial bit for syntax because, like in the syntax of a sentence, it indicates the end. Many students who run into issues with syntax are because of incomplete (i.e., no ending period) statements.
The other part of the editor, on the left side, is a like a table of contents. As your syntax file grows, this can help you quickly find and run code. Your comments will show up here so if you’ve used appropriate comments, you can quickly scan to the right area of the file.
The output viewer window is were you find the results of your analyses, your graphs, and associated syntax that was run to produce the output. Anytime you do something that requires SPSS to generate and run syntax, the output view will make record of it and show the result, unless you are calculating or transforming variables. In that case, the changes are found in the data editor window.
The structure of the output window somewhat mirrors that of the syntax editor with a table of contents on the left and the actual contents on the right (see Figure 2.7).
Figure 2.7
The Output Viewer Window
The output viewer window is more than a viewer; you can actually edit the output, too. This is generally done by double-clicking the item (e.g., a graph or table) that you want to edit. If it is small, you can edit right in the output window. If it is larger, a pop-up editor may open.
If you want to share the results of your analyses (e.g., the content of the output viewer window), you should put it into another file format. Although many in academia and perhaps some in larger corporations have access to SPSS, many do not. SPSS understands this and offers a freely-downloadable standalone output viewer application but that is an extra step. Instead, you can easily export the contents of the output viewer window as a web report, a word file, or image files.
With the major windows introduced, we can now see how SPSS is used
Let’s give SPSS some data, shall we? This can be done in two ways. We can either manually enter the data or we can import it. We’ll walk through both, staring with entering the data manually.
Go to the data editor window (a new one should always open when you open SPSS. Unless you intentionally are opening a data file associated with SPSS). Click on the “Variable View” tab in the bottom-left corner.
Let’s add a “Happiness” variable by typing "Happiness into the “Name” field on the first line.
Ensure that “Type” is set to Numeric (it should default to this).
We’ll add a more descriptive label by typing “Happiness (Unipolar)” in the “Label” box. We’ll call it “Happiness (Unipolar)” because we’ll record the assumed other end of that continuum “Sadness” in another variable.
Emotions are tough to assess so the best we often can get is a Likert-type scale. Let’s set one up for our Happiness variable by adding some value/label pairs in the “Values” field. Click on the first-row cell under “Values” then click the button with the three dots that appears in the cell (see Figure 2.9).
Figure 2.9
Open Values Window Button
This will open the “Value Labels” window (See Figure 2.10). We will need to tell SPSS the dummy code in the “Value” box and the word we want to associate with that code in the “Label” box. Let’s start at the bottom with 0 for the value and “Not Happy” for the label. When you have the boxes filled, click the “Add button”. You must click “Add” after each value-label pair you enter.
Figure 2.10
Value Window
This will move the value-label pair to the box in the center of the window (you’ll see 0 = “Not Happy”). Add in 1 = “Somewhat Happy”, 2 = “Happy”, and 3 = “Very Happy”, being sure to click “Add” after each pair.
When you are done, click the “OK” button in the bottom of the window to return to the Variable View.
Open the “Missing” pop up window by clicking on the three dot button in the cell in the “Missing” column. Choose “Discrete missing values” and enter a unlikely number to mark when there is no data for “Happiness.” I think 999 is very unlikely for a scale ranging from 0 to 3.
Click “OK” to return to the Variable View.
The last property we need to set is the scale of measurement. Likert-type scales are, strictly speaking, always assessed on an ordinal scale of measurement. However, if the data are roughly normally distributed, you can cautiously interpret the results as if the were from an interval scale. The big caveat is, of course, that we cannot claim that an increase from “not happy” to “somewhat happy” is the same magnitude of improvement as from “somewhat happy” to “happy”.
We’ll play it safe and set it to “ordinal”
Let’s set up a “Sadness” variable and a “Gender” variable by following the above steps.
Here are the properties to set for “Sadness”
Here are the properties to set for “Gender”
The final Variable View should look like Figure 2.11
Figure 2.11
Completed Variable View
The variable properties are set so we can proceed to data entry.
Entering data in SPSS is as easy as typing the value in the cell. We just need to ensure that the value we are typing corresponds to the right variable and right person. Always check your data entry to ensure it matches your data source.
If any of your variables are dummy coded, you may want to click that “Value Labels” button in the toolbar. This will allow you to see the labels associated with dummy codes you’ve entered. Also, it will allow you to type the label instead of the dummy code (See Figure 2.12).
Figure 2.12
Typing Dummy Code Label
Enter the following data into the Data View.
Happiness | Sadness | Gender |
---|---|---|
Not Happy | Very Sad | Man |
Very Happy | Not Sad | Woman |
Happy | Somewhat Sad | Man |
Somewhat Happy | Sad | Woman |
Very Happy | Not Sad | Man |
Happy | Somewhat Sad | Woman |
Happy | Sad | Man |
Somewhat Happy | Sad | Woman |
Somewhat Happy | Very Sad | Man |
Not Happy | Very Sad | Woman |
When you’re done, the data view should look like Figure 2.13.
Figure 2.13
Completed Data View
Often, you’ll sharing data with collaborators or you’ll compile the data in a spreadsheet like Excel. In this case, you’ll want to import your data into SPSS. The import process extracts the data from the original file and inserts it into the SPSS file. I recommend working with Comma Separated Values (CSV) files as it is fairly universal file type for data.
Download the import example file for this portion. Be sure to “save as” instead of “open.” On most computers, a CSV file will open in Excel. You cannot import a file that is currently open in Excel. If you do accidentally open the CSV in Excel, save it to your computer (perhaps in Downloads) and close the file. You can then import into SPSS.
To start the import process, go to the “File” menu then hover over “Import Data”. Click on “CSV Data” (see Figure 2.14).
Figure 2.14
Import CSV Menu
You’ll then be directed to select the file which you wish to import. Navigate to the location of the file then select it. When the file is selected, click “Paste” (see Figure 2.15). This will produce some of the necessary syntax to import the file.
Figure 2.15
Selecting the Correct File
The main window for importing CSVs should now be on the screen (see Figure 2.16). The default settings should work 95% of the time but just be sure that if the variable names are the top line, that you check the first box under the preview box. Sometimes, if you have nominal data, SPSS may think that you have variable names included when the first line really contains data. If all looks right, click “Paste” in the bottom again.
Figure 2.16
Import Window
If you are looking for your data after clicking “Paste,” you won’t find it just yet. Remember that clicking “paste” generates syntax only. You’ll also need to run the syntax. Figure 2.17 shows the resulting syntax.
Figure 2.17
Import Syntax
Once the syntax has been run, you should see a new data editor window with values inserted by the import process. The data may look good but you must always check the variable view. Check out the variables and properties from the import in Figure 2.18. They need some attention.
Figure 2.18
Incorrect Variable View
We’ve only mentioned this once but, SAVE YOUR DATA.
SPSS does not have an autosave function so you need to regularly save your files. Did you catch that? Files with an "s’, plural, multiple files. There is a file for each of the three window. The one the data editor has an .SAV file extension. The file for the syntax file is .SPS. Lastly, the file extension for the output window is .spv.
I recommend saving the files in the same location and saving them in the cloud. This will ensure that your files are accessible when and where you need it.
Sometimes, I may ask you to upload one of the files, such as the spv or the sps files. I am more likely to ask you for a specific component of the answer from your output or data editor. The easiest way to do this is to capture a screenshot.
On PC: Push the “windows” key to the left of the spaceabr. Then type “snip” and select the snipping tool from the search results. Click “new” to drag around the area you want to keep. You’ll then need to save it by pressing CTRL + S.
On Mac: Push CMD + SHIFT + 3 to capture the contents of the screen. You can move or edit the photo from the desktop.
SPSS is a user-friendly statistical program that has a point-and-click interface as well as syntax or code control of procedures. It consists of three windows, the data editor, the syntax editor, and the output viewer. Data can be entered manually or imported through a wizard.