Skip to Main Content

DATA 275 Introduction to Data Analytics

Creating a syntax

How to Create and save an SPSS Statistics syntax file

This guide page will walk you through the steps involved in loading an excel file into SPSS while creating a Syntax file. It will use the following file EXAMPLE.XLSX which is saved in the directory: C\SPSSDATA

  1. Open SPSS by double clicking on the SPSS icon on your computer.

  2. You will see the following a dialog box akin to this one:

  3. Click the Cancel button at the bottom right corner of the dialog box.
  4. From the menu ribbon at the top of the data window, click: File, Open, Data

    You should get a dialogue window similar to this one (obviously, not identical)

  5. Notice that the default file type is SPSS Statistics (*.sav). All SPSS Statistics data files have the extension .sav.

    Because we want to load an excel file, we need to change the file type by clicking the down arrow or the right and then making the correct selection. Now the dialog box looks like the one below:

  6. Next we need to go to the directory where the excel file is stored. The file that we are going to open is: Example.xlsx which is in the directory: C\SPSSDATA as shown below:

  7. Place the cursor on the file name EXAMPLE.xlsx and then click the second button on the right labeled Paste. You should be able to see the following dialog box

    If you don't see the dialog box, but get an error saying, (2003) All sheets in Excel file appear to be empty, then see IBM's Support for "(2003) All sheets in Excel file appear to be empty" message when reading Excel file into SPSS via File->Open->Data

  8. Click OK.

    You should get the syntax file window shown below

  9. Click File, Save As to get the following dialog window

  10. Click Save. You have successfully created a syntax file EXAMPLE.sps and are ready to use it. Notice that the file name now appears at the top of the syntax file window

  11. Next, highlight the text in the syntax window and click the green arrow to run it.

    The data file is now open in SPSS.

  12. From the data window, click File, Save AS and then provide the file name EXAMPLE and paste the command to your syntax file. Your syntax file now has the following commands:

  13. From the data file Select: Analyze, Descriptive Statistics, Frequencies

    Select Age and Status as shown below

  14. Click Paste. Your syntax now is as follows…

  15. Highlight the last two sets of commands and click the green arrow to run them. What do you see?
  16. Save your syntax file for future use. You now know how to create and save a syntax file.