Two excellent options exist:
1.) Through a program, like Stat-transfer
2.) Via an SPSS portable file straight into SAS.
*********************************************
Option 1, Stat-transfer is an excellent program for a simple conversion from an SPSS file into a SAS file. It can be used for either an SPSS portable file (.por) or a normal SPSS data file (.sav). This program does cost money, so it isn't a preferred option, unless you need to transfer a variety of file formats into SAS files (i.e. Access, ascii, excel, matlab, minitab, s-plus, STATA, ect.). Stat-transfer is the only transfer program I have used. It has always worked great, so I would recommend this program if you frequently need to import files into SAS from a variety of data formats.
Option 2, Import a portable SPSS file directly into SAS.
The first step is save the SPSS data file as a portable file (.por).
1.) Open the file in SPSS.
2.) Go to File -> Save As...
A new window will open, you will type in the new file name and in the "Save as type" drop down menu, choose "Portable (*.por)". This will save the file into the same folder as the original
SPSS file unless otherwise stated.
***Note: You will see the option of saving the file as "SAS v7+ Windows long extention (*.sas7bdat). This is the normal SAS file extension, but this will often not import into SAS properly.
Now your file is saved as a portable SPSS file, lets get it into SAS.
*****************************************************************************
libname a spss 'd:\SAS Folder\spssfile.por';
*ANNOTATION: With the libname statement we are creating a new library to import SPSS. In this example I am calling the SAS library "a". This is followed by the SPSS command. Lastly, the file location, including the .por extension;
libname b 'C:\SAS Folder';
*ANNOTATION: Now you have imported the file into library "a", which can be found in the explorer tab. If you open the library you see the file as "_first_" however, this file contains errors. So we want to save this into a permanent SAS dataset, so we create a new SAS library with the libname statement;
data b.data;
set a._first_;
run;
*ANNOTATION: Finally, we are saving the SPSS file "a._first_" into a permanent SAS file in the "b" library with the file name "data". Now you will be able to see your SAS dataset in the file-folder “C:\SAS Folder” as "data.sas7bdat";
*****************************************************************************
If you follow these steps the file will be converted from an SPSS dataset into a working SAS dataset, which you may now use for any analysis.
0 comments:
Post a Comment