5. Part III: Managing data in SPSS
5.1. Importing data from Excel to SPSS
One of the more common formats for entering and storing raw data is Microsoft Excel. If you want to work with your data in SPSS, however, you’ll need to import the data from Excel to SPSS. This can be relatively straightforward, but there are a few things to look out for in the conversion process.
We are going to have a go at importing a data file from Excel to SPSS, so that we can see firsthand some of the issues that may come up.
My best advice would be to make sure that you have set up your data well in Excel – this can make the importing process much easier. Also, make sure you take note of a few key data elements in your original data, such as the total number of respondents or records, and the number of variables.
Task: Import data from Excel to SPSS
- Save all your SPSS files, and Close SPSS.
- Open the Excel file you downloaded earlier – HLTH1025_2016.xlsx
- Have a look at how the Data worksheet is set up. For instance, how many records are there? How many variables? What format are the data for each variable? If the data are numeric, make sure the format is set to “Number”.
- When you’re happy with the Excel file, Close it.
- Open your SPSS syntax file.
- Click File > Open > Data …
- Click the “Files of type:” drop down box and select Excel (.xls, .xlsx, .xlsm)
- Navigate to and select the HLTH1025_2016.xlsx file that you saved to your working directory.
- Click “Paste”, to paste the syntax to your syntax file
- A new dialogue box will appear – you should tick the box “Read variable names from first row of data”, as the H&S excel file has variable names in the first row.
- In that same dialogue box, select the “Data” worksheet to import (that’s where the data are stored).
- Click OK. This will paste the syntax to import the data – it hasn’t imported the data yet!
If you have a look at the import syntax, you can see that it’s doing exactly what we told it to do. Similar to the get file command, the get data command also gives you the option to name your dataset.
Select only the get data procedure and click the Run Selection button on the menu bar (the green arrow).
The first thing you should do after importing data from another format is to check your output file to see if there are any error messages. The output file is where you will see whether the syntax you have run has ‘worked’ properly.
In this case, you should not see any error messages, as in the image below:
Also, if you haven’t already put a description (comment) in front of your import syntax, you should do it now!
The next thing to do is to check that the data look like they should, e.g., numeric data has imported as numeric, string data as string, the values look ok, you have the right number of records, the right number of variables, etc. This part requires knowing how to inspect your data in SPSS, which leads us nicely into the next part of this workshop.