Psyc 7291: Multivariate Stats (Carey, 01-15-03)

Converting SAS Data Sets to SPSS.

STEP 1: To do this, we must first convert the SAS data set to an XPORT file format. Assign a LIBNAME statement to the directory where the SAS data set is located. If the directory were ~carey/p7291dir, then the LIBNAME statement could be
LIBNAME prof '~carey/p7291dir';

STEP2: Assign a LIBNAME statement to the file name for the XPORT file format. Make certain to include the qualifier XPORT after the nickname on the LIBNAME statement. If we want to call the file "xdata.xport" and place it in directory ~myname/tempdir, then the following statement will work.
LIBNAME tempx XPORT '~myname/tempdir/xdata.xport';

STEP 3: Use PROC COPY to convert the SAS data set into an XPORT file format. Use the SELECT statement to tell SAS which data sets in the directory to transform into XPORT format. Suppose that you wanted to transfer the data sets called "interest" and "detroit." Then the correct statements would be
PROC COPY IN=prof OUT=tempx;
SELECT interest detroit;
RUN;

STEP 4: Assuming that you are using samiam, go to unix and change to the directory where the SAS XPORT file is located and start up SPSS. The commands are
samiam> cd ~myname/tempdir
samiam> spss &

STEP 5: Go to the syntax window of SPSS, and then enter and submit the following commands:
GET SAS DATA='xdata.xport' DSET='interest'.
SAVE OUTFILE='interest.sav' / COMPRESSED.
GET SAS DATA='xdata.xport' DSET='detroit'.
SAVE OUTFILE='detroit.sav' / COMPRESSED.
The quotes and the period at the end of these statements are necessary.