Another common way that researchers exchange data is through a comma
delimited file called a "CSV" for "comma separated values". CSV files are great,
because everything opens CSV. It's a widely flexible format. Now on the other
hand, CSV does not allow you to store labels and variable settings like an
SPSS file, so it means more work later on.
The most challengin g part about teaching you how to open a CSV file in SPSS is
that I've been using the demo data sets provided by SPSS, but there is no demo
CSV data set. For this illustration, I have created a CSV data set from the
Excel version of the demo data in the Samples folder. I saved our new
demo.csv to my desktop.
To open the CSV, choose File -> Import Data -> CSV Data. from the desktop click on
demo.csv and Open. You see a dialog box titled "Read CSV File" and SPSS will quickly
generate a preview of your data. If you were to click OK, the data would be
imported exactly as they are, including a few data anomalies that will make your
life more difficult. Plus, this preview does not make it particularly easy to
see how your data will actually look. For this reason, I recommend using the Text
Import Wizard when you import data in a CSV. The Text Import Wizard will also
generate a preview of your data, and then open a dialog box that will give you
more options for importing your data. While also doing some important data cleaning.
You can select a predefined format or create a new format in the Wizard.
Leave it set to "No" and click Continue. Select Delimited to indicate that the file has
a delimited formatting structure. Select "Yes" to indicate that the file includes
variable names at the top. The decimal symbol for our numbers is a period.
The delimiter in this file is a tab. It is important that we know that, especially
if we have commas in the numbers of our data, instead of periods as decimals,
or if we have extra spaces. So click Continue. Enter "2" for the line number where the
first case of data begins. Because the variable names are on the first row,
each line (or Row) is a case. We want to import all cases; therefore, these settings can
be kept at their default. Click Continue. Here is where we really begin to see
what our data are going to look like. You see that the default delimiters are
Tab and Space. Now, you may wonder what to do, because I did not show you the
original data set, but don't worry, just look at how the data are going to import.
Unclick the tab delimiter... it got worse didn't it? So re-click it. Click on Comma...
nothing changed, so un-click it. Now notice all of these empty cells.
Under gender, we have M and F but we also have an F over here
and an M over here... this is a mess! But remember that we had some leading spaces
with variables. Let's remove those leading spaces... ah, that is much better!
But look out here on the right... we still have more empty cells, and words that do
not match with numbers. What is happening here is that SPSS is still using spaces
as a delimiter. So the space between the words "Income Category" is creating an
extra colum. To fix this, un-click "Space" as a delimiter.
Feel free to click on other options and see what they do. Your goal here is to keep
clicking until your data are rectangular, and look correct. When they do,
click Continue. We get a warning that SPSS has changed the invalid variable names, such
as "Income Category", and that's good. So click OK.
The variable Marital Status contains both string and numeric values
Fortunately for us, fewer than 5% of the values are words or periods. Leave the
default setting of 95% for "Percentage of values that determine the
Automatic data format". This variable will be treated as numeric and any string
values will be set to system missing. So click Continue.
Leave the default settings in the last step. Click Done to import the data.
The data will open in the SPSS Data Editor. If you want to open another type of text
file other than a CSV, such as a .TXT file, .DAT files, or tab-delimited-formats,
I have a video showing you how to do so also using the Text Import Wizard.