-- -- CSCAR  
-- --   center for statistical consultation and research  
School of Social Work
--
about us
about us
location
workshops
software help
external resources
spatial
jobs
contact
search
--
The Center For Statistical Consultation and Research
3550 Rackham Building
University of Michigan
Ann Arbor, MI 48109-1070
cscar@umich.edu
.
Software Help
 
Importing Data: Converting SAS Data Sets to SPSS
Importing ASCII or Excel data

This handout details the procedure for converting a SAS data set and a SAS formats catalog into SPSS. Although Microsoft Windows/DOS filename conventions are used throughout this document, these instructions will also work on UNIX once the filenames are adjusted accordingly. This procedure is not yet available for the Macintosh version of SPSS. Please note that there is/was a bug in version 5 of SPSS for UNIX that caused SPSS to read SAS missing data values as valid SPSS zeros. It appears to have been fixed for the latest SPSS release that is now installed on the ITD Statistics Login Servers, so it is unlikely that it will affect you. In any case, to be sure the data has transferred properly, double check the descriptive statistics before and after the conversion.

One way in which SAS differs from SPSS is in the treatment of user defined formats or 'value labels'. For example, a variable called SEX may be coded internally as 0 or 1 but have a format that displays the variable as 'MALE' or 'FEMALE'. SPSS stores these value labels within the data set itself. In other words, 1 file contains both the data and the value labels. SAS, on the other hand, stores these formats in a separate file called a formats catalog. An extra step has to be performed within SAS in order to use the SAS formats catalog to create value labels in SPSS.

Whether you have any formats to convert or not, your first step will be to create a transport version of your SAS data set. In general, SAS transport data sets may contain more than one SAS data set but for the purpose of converting to SPSS, your transport data set should only contain one. If you have multiple SAS data sets to convert, you should create a separate transport data set for each one. These SAS commands will perform this first step.


SAS
* Assuming that your SAS data set is in the library SASDATA;
* and that the data set is called OWEN;
libname SASDATA 'c:\sas\mydata\';
libname SAS2SPSS xport 'c:\sas\owen.xpt';
proc copy in=SASDATA out=SAS2SPSS;
select OWEN;
run;

If you do not have any formats to convert, you can skip ahead to the SPSS section. Otherwise, your next step is to convert the formats catalog to a SAS data set and then convert that data set to transport format as in the first step. After submitting these commands you will be ready to exit SAS and start SPSS.

*Assuming that your formats catalog is in the library LIBRARY;
libname library 'c:\sas\catalogs\';
proc format library=library cntlout=fmts;
run;
libname fmt2spss xport 'c:\sas\fmts.xpt';
proc copy in=work out=fmt2spss;
select fmts;
run;

SPSS

You are now ready to run SPSS and finish the conversion process. You can not run the following from the SPSS menus -- you must submit these commands via a syntax window.

If you are converting a SAS formats catalog as well as a SAS data set then you should use these commands.

get sas data='c:\sas\owen.xpt' /formats='c:\sas\fmts.xpt'.
execute .

Otherwise you should run these commands:

get sas data='c:\sas\owen.xpt'.
execute .

SPSS should correctly read all of the standard SAS formats that are available. As always, you should check the data set, both in SAS and in SPSS after the conversion, to confirm that you have the correct number of cases and variables and that the 2 sets of descriptive statistics agree with one another. If you encounter any problems, call CSCAR at 764-7828, stop by our office during our business hours, or send electronic mail to sas.help@umich.edu or to spss.help@umich.edu.

**Note about SPSS versions 11.x and SAS versions 8.x: If you have a permanent copy of your SAS V8.x data set located on your machine (having a .sas7bdat format), you can directly read the data set into SPSS. Simply choose to open a data file of type .sas7bdat from the SPSS File Open menu, locate your SAS V8.x data set, and choose to open the file. SPSS should automatically convert the file for you! If you encounter problems, please contact us.

 
CSCAR Home | About Us | Location | Workshops & Seminars | Software Help | External Resources | Spatial Analysis GIS | Contact Us | Search
 
--
 
Copyright © 1998 - 2001 The Regents of the University of Michigan, Ann Arbor