Skip to content

Error: Failed to parse [...].sav: Invalid file, or file has unsupported features when using haven package to read .sav file #287

@deschen1

Description

@deschen1

I've come across this problem several times now with different data sets that can't be read in with haven package. However, I'm posting it here, because I assume that the problem is with the underlying parsing from ReadStat.

Using the attached data set once it is unpacked (sorry for the file size!) and reading it in with haven in R:

library(haven)
df <- read_sav(file.choose())

I'm getting the following error:

Parsed 12 of 312 bytes. Remaining bytes: 	Q5_990=4000	Q10_90=4000	Q14_90=4000	Q15_90=4000	Q21_90=4000	Q23_90=4000	Q24_90=4000	Q28_90=4000	HQUAL0=2000	HQUAL8=2000	HQUALG=2000	HQUALO=2000	HQUALW=2000	HQUAL14=2000	HQUAL1C=2000	HQUAL1K=2000	HQUAL1S=2000	HQUAL20=2000	HQUAL28=2000	HQUAL2G=20
[731886-data-Rtest3.zip](https://github.com/WizardMac/ReadStat/files/10140850/731886-data-Rtest3.zip)
00	HQUAL2O=2000	HQUAL2W=2000	HQUAL34=2000	HQUAL3C=2000	
Error: Failed to parse [...].sav: Invalid file, or file has unsupported features.

The problem is probably again with some weird or superlong character variables (maybe it's also connected to this multibyte problem?) that SPSS would handle without issues, but haven (or other tools do not).

BTW: When I open the file in SPSS, save it and then try to open it again with haven, it works just fine.

731886-data-Rtest3.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions