How do I use an SPSS setup file to import ASCII data?
Setup files contain the syntax or program code to read undelimited data (ASCII) into a statistical package. The instructions below demonstrate how to use SPSS setup files in a Windows environment.
These instructions assume that you have already downloaded the ASCII data and SPSS setup file from the Internet. If you have a compressed version of a file, you will have to decompress it before using the setup files.
Note: In order to successfully use setup files, you must know the exact location (i.e., full pathname, such as C:\My Documents\Data) and filename (e.g., da9999.txt) of the files that you downloaded.
Download the SPSS setup file from the ICPSR Web site.
Most of the files downloaded from the ICPSR Web site will be compressed. You will have to decompress the files using WinZip or other decompression software. Once the SPSS setup file has been downloaded and decompressed, rename the file to add the '.sps' extension. This will allow SPSS to recognize the file as an SPSS syntax file. Do not save the setup file on your local machine with the ".txt" extension because SPSS for Windows will try to read it as a data file rather than a syntax file.
Open SPSS for Windows.
Open the SPSS setup file in the SPSS for Windows Syntax Editor.
If a dialog window of shortcuts opens, close it by clicking the 'Cancel' button.
Click on File and then Open to get an Open File dialog box.
At the top of the box, where it says Look In, choose the path where the SPSS setup file is located.
At the bottom of the box, set Files of Type to All Files to see a listing of all files in a particular directory or to Syntax (*.sps) if you saved the setup file with an '.sps' extension.
You will then see a list of files in the directory you selected. Either double-click on the SPSS setup file or click once on the name of your chosen file (the name will appear after File Name) and then click on Open.
Since the SPSS setup file is a text file, SPSS will open a new Syntax Editor window to display the file.
If you try to open the SPSS setup file and you are prompted with a dialog box that says Opening File Options, then press Cancel. SPSS is trying to read the setup file as a data file rather than a syntax file. This is likely to happen if your setup file has a ".txt" extension. You can either rename the file and remove the ".txt" extension or you can open the setup file in an editing program and copy and paste the text into the SPSS for Windows Syntax Editor.
Most ICPSR setup files contain a header that describes the contents of the file. Once you have opened the setup file in the SPSS for Windows Syntax Editor, read the ICPSR header, if present, for important information about what is contained in the file.
After reading the header, scroll to the DATA LIST command. Replace the text that says physical-filename or file-specification with the full path and name of the data file extracted from the downloaded file.
It is important that you include the full path (e.g., C:\My Documents\Data); otherwise SPSS may not be able to locate the file. For example, if you extracted the data for ICPSR 2992 into the directory C:\My Documents\Data and you called the file da2922.txt, then the DATA LIST command should read:
DATA LIST FILE="C:\My Documents\Data\da2992.txt" /
If there is a MISSING VALUES command in the setup file, ICPSR usually places an SPSS comment delimiter (*) before the command line, which means that SPSS will not read this command. If you want SPSS to read this command, you should delete the asterisk and be sure that the command starts in the first column of the line.
Some SPSS setup files also contain a missing value RECODE command. This command may also have an SPSS comment marker (*) at the beginning of the line. If you want SPSS to read this command, you should delete the asterisk and be sure that the command starts in the first column of the line. When both a MISSING VALUES and missing value RECODE command are present in the same SPSS setup file, only one of the two commands should be executed. Choose MISSING VALUES if you want to retain the missing values in the data, but have them designated as missing values by SPSS for analysis purposes. Choose missing value RECODE if you want missing values converted to system missing. Please note that the missing value RECODE command may collapse several different missing values for one variable into system missing.
Scroll to the end of the setup file. If an EXECUTE command is not already there, then type one in. Start the command in the first column of a new line and end the line with a period.
You are now finished editing the SPSS setup files. Run the statements by clicking on Run -> All. The status bar at the bottom of the screen will show the commands that SPSS is processing. When SPSS has completed executing the commands, the status bar will display the message "SPSS for Windows Processor is ready."
When the processor is finished, go to the Window menu and choose SPSS for Windows Data Editor to see the data. Any error messages will be printed in a log file in the SPSS Output window.
If you do not see the data appear in the SPSS Data Editor, check the status bar in the lower left corner of the screen. If the status bar says Transformations Pending, go to the Transform Menu and click on Run Pending Transformations. This is usually necessary when you do not have an Execute command at the end of the setup files.
Once you have read the data into the SPSS Data Editor, you may then start subsequent sessions using the imported data. You can bypass having to import the data with the SPSS setup files every time you want to access the data by saving the imported data on storage media; go to the File menu and click on Save As ... to save the file as either an SPSS system or portable file. Specify the directory where you would like to store the file using the Save in: box, enter a Filename, and choose the type of file you would like the data saved as. You can then begin subsequent SPSS sessions by opening the saved file from the Data Editor window.
For further help with SPSS for Windows, consult the HELP menu on the top toolbar of SPSS or refer to the SPSS for Windows Base System User's Guide.
This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 United States License.