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;

2. In SPSS, run this syntax:
  SAS DATA ='G:\argentina\tango_baseline.sas7bdat'
      /FORMAT ='G:\argentina\sas_fmts.sas7bdat'.

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

No comments: