December 6, 2009

Covert SAS dataset to SPSS with formats

Often I want to include the SAS variable formats when I hand-off a database in SPSS. Our research group sets up all databases in SAS, but some investigators prefer to work in SPSS for analysis. Here are the steps I use:

1. In SAS, save your formats files as a SAS dataset:
libname tango 'G:\argentina';
libname mylib 'G:\library';
proc format library = mylib cntlout=tango.sas_fmts;
run;


2. In SPSS, run this syntax:
GET
  SAS DATA ='G:\argentina\tango_baseline.sas7bdat'
      /FORMAT ='G:\argentina\sas_fmts.sas7bdat'.
  DATASET NAME Tango WINDOW=FRONT.

3. In SPSS, once you see the data in the editor, save the dataset as *.sav

No comments: