-- -- 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 SPSS Data Sets to SAS
This handout details the procedure for converting a SPSS data set into SAS. Although UNIX/ITD Statistics Servers filename conventions are used throughout this document, these instructions will also work on Windows or Macintosh once the filenames are adjusted accordingly.

SPSS portable files can be read into SAS using the SPSS engine. The SPSS engine is simply a program that translates SPSS portable files into SAS data sets. The form of the commands to translate an SPSS file into SAS are as follows:

libname libref1 spss 'name of subdirectory and file
containing SPSS data';
libname libref2 'subdirectory where sas dataset will be
stored';

proc convert spss=libref1 out=libref2.new-dataset-name;

proc means data=libref1.new-dataset-name;
For example, if I had an SPSS portable file named bank.por, and I wished to create a permanent SAS data set within my subdirectory called '~/cscar', I could issue commands as shown below:
libname bankpor spss '~/cscar/bank.por';
libname sasdata '~/cscar';

proc convert spss=bankpor out=sasdata.bank;
run;

proc means data=sasdata.bank n mean std;
title 'Checking on Transformation of Data from SPSS to SAS';
run;
In the commands shown above, the libref bankpor points to the spss portable file, ~/cscar/bank.por. It also assigns the engine SPSS to read this file. The libref sasdata points to the subdirectory ~/cscar. This is the subdirectory where the permanent SAS data set will be stored after the transformation from SPSS. The proc convert statement copies the SPSS portable file to the permanent SAS dataset sasdata.bank. The Proc Means statement is used as a check on the importing of the data to see if they look correct in SAS.

A copy of the SAS log for these commands is shown below:

1 libname bankpor spss '~/cscar/bank.por';
NOTE: Libref BANKPOR was successfully assigned as follows:
Engine: SPSS
Physical Name:
/afs/umich.edu/user/m/y/myhome/cscar/bank.por
2 libname sasdata '~/cscar';
NOTE: Libref SASDATA was successfully assigned as follows:
Engine: V609
Physical Name: /afs/umich.edu/user/m/y/myhome/cscar
3
4 proc convert spss=bankpor out=sasdata.bank;
5 run;

NOTE: Using the libref BANKPOR, which has already been
assigned to the file
/afs/umich.edu/user/m/y/myhome/cscar/bank.por.
NOTE: SPSS Portable File (Creation Date=11MAR96:20:00:59).
NOTE: File label: '05.00.00'.
NOTE: The data set SASDATA.BANK has 474 observations and
11 variables.
NOTE: PROCEDURE CONVERT used:
real time 0.55 seconds
cpu time 0.35 seconds

6
7 proc means data=sasdata.bank n mean std;
8 title 'Checking on Transformation of Data from SPSS to SAS';
9 run;

NOTE: The PROCEDURE MEANS printed page 1.
The output of the Proc Means is shown below:
Checking on Transformation of Data from SPSS to SAS 1
20:15 Monday, March 11, 1996

Variable Label N Mean Std Dev
--------------------------------------------------------------------
ID Employee code 474 876.5970464 146.4667742
SALBEG Beginning salary 474 6806.43 3148.26
SEX Sex of employee 474 0.4556962 0.4985595
TIME Job seniority 474 81.1097046 10.0609449
AGE Age of employee 474 37.1861392 11.7872421
SALNOW Current salary 474 13767.83 6830.26
EDLEVEL Educational level 474 13.4915612 2.8848464
WORK Work experience 474 7.9886076 8.7154111
JOBCAT Employment category 474 2.0590717 1.4054755
MINORITY Minority classification 474 0.2194093 0.4142836
SEXRACE Sex & race classification 474 2.1308017 1.0504105
--------------------------------------------------------------------
If later you wished to use this permanent data set in SAS, you could issue commands as shown below:
libname sasdata '~cscar';

proc freq data=sasdata.bank;
tables sex edlevel jobcat;
title 'frequencies of selected variables';
run;

 
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