Converting SAS datasets to SPSS

If you want to view SAS dataset in SPSS you can use GET SAS command of SPSS.

Here is the syntax;
get sas data='C:\data\class.sas7bdat'.

For conversion of SAS to SPSS we need to see if any formats assigned to variables in the dataset or not.
If there are no formats then we just follow following steps to convert SAS dataset to SPSS.

**STEP1: Creating .xpt file of a SAS dataset using Proc COPY.**

libname SAS 'c:\sas\data\';
libname SPSS xport 'c:\sas\data\class.xpt';

proc copy in=sas out=spss;
select class;
run;


**STEP2: Use SPSS command to convert the transport format SAS file to SPSS;**


You should use following commands to convert transport format file to SPSS data.


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

*******************************************************************************************;
If there are formats then we need to convert the formats catalog to a SAS data set before converting the SAS dataset into a .XPT file. This has to be done inside SAS to use the SAS formats as the value labels for SPSS data.

**STEP1: Creating .xpt file of a SAS dataset using Proc COPY.**


libname formats 'c:\sas\catalogs';

proc format library=formats cntlout=fmts;
run;


***Transport file of SAS formats;**


libname fmt2spss xport 'c:\sas\fmts.xpt';


proc copy in=work out=fmt2spss;
select fmts;
run;

***Transport file of SAS dataset.**


libname SAS 'c:\sas\data';
libname SPSS xport 'c:\sas\data\class.xpt';


proc copy in=sas out=spss;
select class;
run;


**STEP3: Use SPSS command to convert the transport format SAS file and Formats to SPSS;**


*Use following SPSS command to convert transport format file to SPSS data;


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

('DiggThis’)

Popular posts from this blog

SAS Interview Questions and Answers: CDISC, SDTM and ADAM etc

Comparing Two Methods for Removing Formats and Informats in SAS: DATA Step vs. PROC DATASETS

Studyday calculation ( --DY Variable in SDTM)