Hi
I need to convert some SAS data sets into SPSS data sets. The SAS data set have labels and formats and some variables have long variable name (>8 characters). My clients wants the data for SPSS with corresponding labels and formats.
I was adapting the code from this website (http://www.runsubmit.com/questions/240/convert-data-from-from-sas-to-spss-using-sas ) but I am hitting problems when trying to create a transport file of the SAS data set, due to longer variable name lengths.
Does anyone know how I can do it without having to rename variables in the data sets?
:smileyinfo: I am using SAS v9.3 (64-bit), need to convert for SPSS v20.
Thanks
Peta
Personally I use STAT/Transfer.
You probably do NOT want to use SAS version 5 transport files as those will be limited to 8 character variable names and maximum length of 200 for character variables.
If you are desperate and know SPSS syntax well enough just get the variable names from the SAS metadata (or use PROC CONTENTS OUT=) and generate the SPSS code to read from a CSV file. As the thread you link noted you can get the "value labels" of user defined formats using the CNTLOUT option on PROC FORMAT and use those to generate SPSS code.
Thanks Tom for your reply. Just before I received your reply, I had figured it out (well, one way of doing it)
Step 1 : create a data set from the formats catalog
LIBNAME FMTDIR "C:\DATA - FINAL\FMTDIR";
LIBNAME LIBRARY "C:\DATA - FINAL\FMTDIR";
PROC FORMAT LIBRARY=LIBRARY.FORMATS CNTOUT=FMTDIR.FMT_DATA; RUN;
Step 2 : export to an .SAV file using the FMTLIB option in the PROX EXPORT procedure (using the formats data set)
LIBNAME FMTDIR "C:\DATA - FINAL\FMTDIR";
LIBNAME DIR1 "C:\DATA - FINAL";
PROC EXPORT
DATA= DIR1.SAS_DATA_1 OUTFILE= "C:\SPSS_DATA_1.SAV" DBMS=SPSS REPLACE ;
FMTLIB=FMTDIR.FMT_DATA;
RUN;
This seems to have worked okay - longer variable name lengths preserved, formats/values exported into the SPSS file, etc.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.