14 Answers
14

I had a similar issue and solved it following a hint in read.spss help.
Using package memisc instead, you can import a portable SPSS file like this:

data <- as.data.set(spss.portable.file("filename.por"))

Similarly, for .sav files:

data <- as.data.set(spss.system.file('filename.sav'))

although in this case I seem to miss some string values, while the portable import works seamlessly. The help page for spss.portable.file claims:

The importer mechanism is more flexible and extensible than read.spss and read.dta of package "foreign", as most of the parsing of the file headers is done in R. They are also adapted to load efficiently large data sets. Most importantly, importer objects support the labels, missing.values, and descriptions, provided by this package.

I know this post is old, but I also had problems loading a Qualtrics SPSS file into R. R's read.spss code came from PSPP a long time ago, and hasn't been updated in a while. (And Hmisc's code uses read.spss(), too, so no luck there.)

The good news is that PSPP 0.6.1 should read the files fine, as long as you specify a "String Width" of "Short - 255 (SPSS 12.0 and earlier)" on the "Download Data" page in Qualtrics. Read it into PSPP, save a new copy, and you should be in business. Awkward, but free.

It looks like the R read.spss implementation is incomplete or broken. R2.10.1 does better than R2.8.1, however. It appears that R gets upset about custom attributes in a sav file even with 2.10.1 (The latest I have). R also may not understand the character encoding field in the file, and in particular it probably does not work with SPSS Unicode files.

You might try opening the file in SPSS, deleting any custom attributes, and resaving the file.
You can see whether there are custom attributes with the SPSS command

Used display attributes. in a syntax file and I get a warning telling me there are no attributes to display. Some of the string fields are 2000 length, should that matter?
– Btibert3Jun 29 '10 at 12:57

1

Hi Jon - I tried Deleting the attributes with the following syntax. Did have a few, removed them, still no luck *//// Display the Custom attributes. DISPLAY ATTRIBUTES. *//// DELETE all for every variable with custom attributes. VARIABLE ATTRIBUTE VARIABLES=GameID TO OUTCOME_DIFF DELETE=$ODBC.Name. VARIABLE ATTRIBUTE VARIABLES=GameID TO OUTCOME_DIFF DELETE=$ODBC.Table. VARIABLE ATTRIBUTE VARIABLES=GameID TO OUTCOME_DIFF DELETE=$ODBC.Size. VARIABLE ATTRIBUTE VARIABLES=GameID TO OUTCOME_DIFF DELETE=$ODBC.Type. *//// Confirm that they are removed and manually save. DISPLAY ATTRIBUTES.
– Btibert3Jun 30 '10 at 1:41

You can read SPSS file from R using above solutions or the one you are currently using. Just make sure that the command is fed with the file, that it can read properly. I had same error and the problem was, SPSS could not access that file. You should make sure the file path is correct, file is accessible and it is in correct format.

library(foreign)
asq <- read.spss('ASQ2010.sav', to.data.frame=TRUE)

As far as warning message is concerned, It does not affect the data. The record type 7 is used to store features in newer SPSS software to make older SPSS software able to read new data. But does not affect data. I have used this numerous times and data is not lost.

If you have access to SPSS, save file as .csv, hence import it with read.csv or read.table. I can't recall any problem with .sav file importing. So far it was working like a charm both with read.spss and spss.get. I reckon that spss.get will not give different results, since it depends on foreign::read.spss

2.10.1 - updated all packages. I am getting the SPSS file from another software.
– Btibert3Jun 29 '10 at 12:56

Which one, if we may know? I'm not interested in particular SPSS version "per se", I just need to know is it SPSS or PASW file... maybe it has something to do with changes made latest releases... Dunno... =(
– aL3xaJun 29 '10 at 21:01

There is no such problem with packages you are using. The only requirement for read a spss file is to put the file into a PORTABLE format file. I mean, spss file have *.sav extension. You need to transform your spss file in a portable document that uses *.por extension.

In my case this warning was combined with a appearance of a new variable before first column of my data with values -100, 2, 2, 2, ..., a shift in the correspondence between labels and values and the deletion of the last variable. A solution that worked was (using SPSS) to create a new dump variable in the last column of the file, fill it with random values and execute the following code:
(filename is the path to the sav file and in my case the original SPSS file had 62 columns, thus 63 with the additional dumb variable)

I've found the program, stat-transfer, useful for importing spss and stata files into R.

It resolves the issue you mention by converting spss to R dataset. Also very useful for subsetting super large datasets into smaller portions consumable by R. Not free, but a very useful tool for working with datasets from different programs -- especially if you don't have access to them.

Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).