BookmarkSubscribeRSS Feed
Emma_at_SAS
Lapis Lazuli | Level 10

I am using the following code to read a dataset from SPSS into SAS.

proc import datafile = "d:\path\dataset.sav"
dbms = sav replace
out = SAS_file_name;
fmtlib = WORK.FORMATS;
run;

My SAS Log says

Unknown internal variable type
ERROR: Import unsuccessful. See SAS Log for details.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.26 seconds
cpu time 0.00 seconds

It sounds the problem is "SPSS v12 supports variable names up to 64 characters in length. Proc Import of these files results in the truncation of the longer variable names to 8 characters." https://support.sas.com/kb/19/383.html

I checked the "Hot fix" tables but could not find the fix to this issue. I appreciate it if you may help me with this. Thanks

7 REPLIES 7
AMSAS
SAS Super FREQ

What version of SAS are you running?
This looks like it was addressed in 9.1.3, via hot fix click the Hot Fix tab in the Usage Note you found & 9.2

If you are running a later version of SAS then I recommend opening a track with Technical Support and provide the following:

  • Describe the problem as you have done here, with the Usage Note link, log etc.
  • Output from the following SAS code:
%put &sysvlong ;
%put &sysscpl ;
%put &syssite ;
  • Registry Report (*.txt files) for each server, please clearly name the report files to reflect the server it was executed on
  • Has this run successfully in the past?
  • When did it stop running successfully?.
  • Has anything changed since it was last running successfully?

 

 

ballardw
Super User

Try using DBMS=SPSS.

 

SAS variable names are restricted to 32 characters at this time. So long names will be truncated.

And if you have an anywhere near current SAS/Access Interface to PC Files licensed it should handle at least SPSS V18. So I think you are looking at at out of date documentation.

Emma_at_SAS
Lapis Lazuli | Level 10

Thank you very much AMSAS and ballardw for checking my questions and your suggestions. I tried DBMS=SPSS but still, I get the same message for "Unknown internal variable type".

I checked "Importing and Exporting SPSS Files" and tried the following code which imports format as well (I want the formats once I can read the data set). I will check with SAS technical support then. Thanks

LIBNAME A '.';
PROC IMPORT DATAFILE="d:path\test.sav" 
	OUT=SAS_dataset DBMS=SPSS;
	FMTLIB=A.FORMATS_SPSS;
RUN;
ballardw
Super User

@Emma_at_SAS wrote:

Thank you very much AMSAS and ballardw for checking my questions and your suggestions. I tried DBMS=SPSS but still, I get the same message for "Unknown internal variable type".

I checked "Importing and Exporting SPSS Files" and tried the following code which imports format as well (I want the formats once I can read the data set). I will check with SAS technical support then. Thanks

LIBNAME A '.';
PROC IMPORT DATAFILE="d:path\test.sav" 
	OUT=SAS_dataset DBMS=SPSS;
	FMTLIB=A.FORMATS_SPSS;
RUN;

Which version of SPSS created the data set? If it is later than the versions SAS supports you may have to do some sleuthing to find out what the problem is. One might suspect some version of SPSS has variables that exceed the expected lengths.

Do you have access to the SPSS program? You might try exporting the data to a text format such as CSV and read that.

 

Or you may have to contact SAS tech support and share the SPSS file and see what they suggest.

Emma_at_SAS
Lapis Lazuli | Level 10

Thank you, ballardw, for your suggestions! I do not have access to SPSS, my teammates do. Last time they sent me the SAS version of the dataset exported from SPSS. I could read that dataset but I did not check if any variable name was truncated to 32 characters. The variables for my analyses were fine though. 

 

I will ask them to send me the version of their SPSS software and the SAS version of the dataset and see which way I can access their dataset in SAS.

Thanks!

ballardw
Super User

One of the recurring themes with Proc Import and proprietary files, such as SPSS data files, is that SAS is limited to information published by that third party to read data. The versions of software releases is often ahead of sharing that information so Proc Import will lag behind possible file variations. My experience with SPSS is pretty old as I last used the program when it was version 10. However at that time every SPSS release forced us to change and re-document procedures because features were removed or modified such that programs had to be rewritten.

 

If your compatriots are using a later version of SPSS I strongly suggest, if at all practical, that they do the SAS file creation and don't forget the format files you'll need to handle any value labels.

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 Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1366 views
  • 5 likes
  • 3 in conversation