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
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:
%put &sysvlong ;
%put &sysscpl ;
%put &syssite ;
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.
Nice catch @ballardw missed that
@Emma_at_SAS please see Importing and Exporting SPSS Files
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;
@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.
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!
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.
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: