-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPSS Error # 1405 when reading haven-created SAV files containing 256+ byte strings #266
Comments
Should be fixed in WizardMac/ReadStat@f6aef4c |
Great. Can I test with my real example already or do I need to wait until this is pulled into haven? |
I think this fix just barely missed the 1.1.0 cutoff, so you'll have to wait until it gets pulled into haven. |
Never mind. I managed to fix the issue myself by adjusting the readstat_sav_read.c and #define MAX_STRING_SIZE 2000 At last I just want to thank you for creating an awesome package!! :). @evanmiller When do you expect to have this fix pulled into haven? I am experiencing the same issue as @rubenarslan . SPSS won't open a .sav saved using write.sav if of the saved dataframe contains a string with more than 255 bytes. I've tried to manually adjust ReadStat as you mentioned in the fix. However, this didn't seem to work :/ |
This appears to still be a problem even with latest readstat |
Error message from #346:
My current theory is as follows. Variables in an SAV file contain a "virtual" variable for each 256-byte chunk. ReadStat gives each virtual variable the same name. However, in the sample file provided, it appears that SPSS assigns a unique name to each virtual variable (e.g. |
PSPP has this to say:
|
Does it help you verify your theory if I generate files with more 5*256 letters or so? |
Possibly fixes tidyverse/haven#266
@rubenarslan I just updated haven with @evanmiller's latest code. Can you please try again now? |
Unfortunately, the same error occurs after an update with devtools. I also attached a 512 character-string file in case that helps.
Edit: Sorry, just realised I should have made the long file with SPSS, not R. Stupid. Here it is: test_720.sav.zip |
Thanks. Might be an issue with the Variable Display Parameter... I'll have another update to test soon. |
The Variable Display Parameter record contains information about ordinality and text alignment. Previously, one entry was emitted for each real variable. However, SPSS emits an entry for ghost variables as well. This change mimics the SPSS behavior, and possibly fixes tidyverse/haven#266
@hadley Try the latest ReadStat. For future reference someone should give this issue a more descriptive name e.g.
|
@evanmiller that might well be it. In SPSS you also cannot lengthen a string without first increasing the variable display parameter. I'll try with the next update. |
@rubenarslan try now |
Well, it now writes the 256 character file and SPSS can open it. Yay! |
I just noticed that 256 chars
512 chars
1024 chars
|
@rubenarslan Please open new and separate issues against ReadStat for these. Note that ReadStat has a command-line interface, so we should be able to debug these without getting haven involved.
|
More feedback, i don't know if this has anything to do with the labels, since the data column to which SPSS refers in its error message was not changed referring: SPSS Error # 1405 |
Closing since this thread is long and seems to combine multiple issues. Please file new issues (with reprexes) if you're still seeing problems. |
The original issue has been fixed in ReadStat. WizardMac/ReadStat#122 |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
SPSS (v.20.0) cannot read files written by haven if there are any strings longer than 255 characters (or bytes, strings with umlauts need to be shorter still).
to reproduce
test files
I made three test files.
In all, I wrote a long string consisting of "a" with one "b" at the end.
test_files.zip
original discusson
PS.: @evanmiller Let me know if I should raise these issues directly in ReadStat. I only use ReadStat through haven though, so wouldn't be able to make reprexes.
The text was updated successfully, but these errors were encountered: