How to Format a Text File for Input into SPSS

By Keith McCormick, Jesus Salcedo, Aaron Poh

If your data is in an application that can’t directly create a file of a type that SPSS can read, getting the data into SPSS may be easier than you think. If you can get the information out of your application and into a text file, it’s fairly easy to have SPSS read the text file.

When it comes to writing information to disk, some applications are more obliging than others. Look for an Export menu option — it usually has some options that allow you to organize the output text in a form you want.

If the application doesn’t allow you to format text the way you want, look for printer options — maybe you can redirect printer output to a disk file and work from there. If you use the application’s printer output, you may need to use your word processor to clean up the form of the data. This multistep operation sounds like a lot of work, but it’s often easier than typing all your data in again by hand.

The data file you output from SPSS doesn’t have to include the variable names, just the values that go into the variables. You can format the data in the file by using spaces, tabs, commas, or semicolons to separate data items. Such dividers are known as delimiters. Another method of formatting data avoids delimiters altogether. In that method, you don’t have to separate the individual data items, but you must make each data item a specific length, because you have to tell SPSS exactly how long each one is.

The most intuitive format is to have one case (one row of data) per line of text. That means the data items in your text file are in the same positions they’ll be in when they’re read into SPSS. Alternatively, you can have all your data formatted as one long stream, but you’ll have to tell SPSS how many items go into each case.

Always save this kind of raw data as simple text; the file you store it in should have the .txt extension so SPSS can recognize it for what it is.