BookmarkSubscribeRSS Feed
julicny
Obsidian | Level 7

I am working on a project where I need to import data into SAS from SPSS and then export back to SPSS after I finish working with the data.  The problem is that when I import the data back into SPSS the numeric formatting changes to integer from the original SPSS format settings. 

 

Here is an example of code I used:

PROC IMPORT OUT= BMT.SPSS_check_fmt
			DATAFILE= "C:\bmtdata\TestSPSS.sav"
            DBMS=SPSS REPLACE;
run;


PROC EXPORT DATA= BMT.SPSS_check_fmt
            OUTFILE= "C:\bmtdata\TestSPSSout.sav"
            DBMS= SAV REPLACE;
run;

 

For instance one variable's format was 8.2 and when it came back into SPSS it was 8.0 even though the variable was unaltered by SAS in any way.  The underlying data is still correct.  When I try to open the SPSS data exported from SAS I get this message:

SPSS.jpg

Is there a workaround for this issue short of having to re-format all the numeric data every time I import it back into SPSS? 

Any insights you can provide on the most practical way to handle this situation would be greatly appreciated.  Thanks.

 

1 REPLY 1
ChrisHemedinger
Community Manager

When you import from SPSS, SAS creates a separate set of SAS format definitions to store any special "label" assignments from the SPSS data.  I'm not sure that's what is happening here, but it's probably a good idea to check whether any formats are created and whether they are present when you export back.  This article (about a task in SAS Enterprise Guide) provides a little bit of background.

 

Also, I see that you're using DBMS=SPSS when you import, but SAV on export.  SAV should be used in both cases, though SPSS might be just an alias for SAV in this syntax.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 918 views
  • 0 likes
  • 2 in conversation