[R] Read SPSS v 18 .sav file

David Winsemius dwinsemius at comcast.net
Fri Jun 18 17:36:40 CEST 2010


On Jun 18, 2010, at 10:44 AM, David Winsemius wrote:

>
> On Jun 18, 2010, at 10:26 AM, Larry Hotchkiss wrote:
>
>> Hi,
>>
>> I repeatedly get an error when trying to read an SPSS v. 18 .sav  
>> file into R.
>
> No, you did not get an error message.
>>
>>> require(foreign)
>> Loading required package: foreign
>>> femaleSPSS.dat <- read.spss("female-04-02-2010.sav")
>> Warning message:
>> In read.spss("female-04-02-2010.sav") :
>> female-04-02-2010.sav: Unrecognized record type 7, subtype 18  
>> encountered in system file
>>>
>>
>> However, read.spss works for .sav files created in older versions  
>> of spss.
>>
>> I did just reinstall foreign to be sure I have the latest version.  
>> Does anyone know of an update that works?
>
> What makes you think it didn't work? It was _only_ a warning message  
> after all. Have you looked at femaleSPSS.dat in your workspace?
>
> Had you done a search of the archives you would have found many such  
> early discussions:
>
> RSiteSearch("Unrecognized record type 7, subtype 18 encountered in  
> system file")

I realized looking at this that my standard operating procedure (these  
days) was to use RSiteSearch() as a way to get to the webpage, and  
then when I realize that it no longer actually looks at the archives  
of r-help to turn off all of the default settings and turn on all of  
the archive settings. I earlier tried to craft a substitute function  
that would send the site an r-help-centric request, but found that the  
search engine would not accept my guess at the correct parameters for  
the three time periods that I am generally finding useful material  
within:

R-help 2008-2009
R-help 2010-
R-help 2002-2007

I am aware that the sos package might be a more flexible set of tools,  
but I really like the RSiteSearch format. I've just looked at the code  
and it appears the functions settings have been updated. This would do  
the trick:
RSiteSearch("Unrecognized record type 7, subtype 18 encountered in  
system file", restrict=c("Rhelp10", "Rhelp08", "Rhelp02"),  
matchesPerPage = 100)

And now I have the facilities to make my desired function:

rhelpSearch <- function(string,
                    restrict = c("Rhelp10", "Rhelp08", "Rhelp02",  
"functions" ),
                    matchesPerPage = 100, ...)
           RSiteSearch(string=string,  restrict = restrict,   
matchesPerPage = matchesPerPage, ...)

#testing:
 > RHSrch("Unrecognized record type 7, subtype 18 encountered in  
system file")
# Succeeds

Thanks to whomever updated RSiteSearch.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list