Exporting to .sav works but won’t open in SPSS

Discuss the jamovi platform, possible improvements, etc.
DeborahA
Posts: 22
Joined: Tue Apr 14, 2020 11:38 am

Exporting to .sav works but won’t open in SPSS

Post by DeborahA »

Hi all,

I have a query from a student who is using jamovi for their data analyses, but needs to send it to their supervisor in SPSS format (because none of our academics will bother to download jamovi). The file seems to export OK, but then it will not open in SPSS. I have been able to replicate this issue with one of my more complex data files. It’s not the same as previous issues I’ve seen with illegal characters - at least, I don’t think so, because it seems to export OK. Do you have any idea what the problem could be? I had a student in a previous year who discovered that even a variable description starting with a number could cause a problem in a .sav file. But I’m not sure that is the problem this time (and the student says they have already checked for “illegal characters” in variable names).

Interestingly, I was able to reproduce the problem by opening a file that was ORIGINALLY a .sav file in jamovi, then exporting it as a .sav file without doing anything to it. The exported file will not open in SPSS, even though the original file will. So there’s something going on with the jamovi export, but I can’t tell what it is. The SPSS error message is not informative - it just says “error when attempting to get a data file”. If it helps, all the files I’ve had trouble with are Qualtrics data.

Thanks for any help!

Cheers

Deborah.
DeborahA
Posts: 22
Joined: Tue Apr 14, 2020 11:38 am

Re: Exporting to .sav works but won’t open in SPSS

Post by DeborahA »

Just an addendum: I did manage to get around the problem by reading the exported .sav file into R using haven, and then writing it back to file from haven without any changes. It will then open in SPSS. Super weird.
User avatar
jonathon
Posts: 2627
Joined: Fri Jan 27, 2017 10:04 am

Re: Exporting to .sav works but won’t open in SPSS

Post by jonathon »

yeah, that is odd. we use the same library to open/save files as haven, so it's surprising.

if you email the file through to contact <at> jamovi.org, and provide the steps to reproduce, i can take a look.

cheers

jonathon
DeborahA
Posts: 22
Joined: Tue Apr 14, 2020 11:38 am

Re: Exporting to .sav works but won’t open in SPSS

Post by DeborahA »

Hi again Jonathon,

That email address does not seem to be working. Sorry, could you give me an exact email?

A little extra info:

The SPSS error message also always says:

Code: Select all

>Error.  Command name: GET FILE
>Invalid SPSS Statistics data file: JamoviExport_CombinedData_rescored.sav (DATA1204)
>Execution of this command stops.

>Error # 1405 in column 8.  Text: JamoviExport_CombinedData_rescored.sav
>Error when attempting to get a data file.

SPSS website says this means it is a corrupt file. https://www.ibm.com/support/pages/node/502821

There’s also this GitHub issue page: https://github.com/tidyverse/haven/issues/266

Could it be you’re using an earlier version of haven?


Best

Deborah.
DeborahA
Posts: 22
Joined: Tue Apr 14, 2020 11:38 am

Re: Exporting to .sav works but won’t open in SPSS

Post by DeborahA »

Update: Aha!! Running the write_sav command from the R command line in jamovi suggests this is indeed the problem:

Code: Select all

Debug

Error in `write_sav()`:
! SPSS only supports levels with <= 120 characters.
✖ Problems: `MTBI_effects`

private$.run()
eval(code, self$data, echo, self$results, figWidth = figWidth, figHeight = figHeight, saveColumns = self$saveColumns)
evaluate::evaluate(input = script, envir = eval.env, output_handler = handler, stop_on_error = 2)
evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos, debug = debug, last = i == length(out), use_try = stop_on_error != 2, keep_warning = keep_warning, keep_message = keep_message, output_handler = output_handler, include_timing = include_timing)
timing_fn(handle(ev <- withCallingHandlers(withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers)), warning = wHandler, error = eHandler, message = mHandler)))
handle(ev <- withCallingHandlers(withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers)), warning = wHandler, error = eHandler, message = mHandler))
withCallingHandlers(withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers)), warning = wHandler, error = eHandler, message = mHandler)
withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers))
eval_with_user_handlers(expr, envir, enclos, user_handlers)
eval(expr, envir, enclos)
eval(expr, envir, enclos)
write_sav(data, "/Users/deborahapthorp/Desktop/Rowena_Qualtrics_data_from_jamovi.sav")
validate_sav(data)
cli_abort(c("SPSS only supports levels with <= 120 characters.", x = "Problems: {.var {var_names(data, bad_lengths)}}"), call = call)
rlang::abort(message, ..., call = call, use_cli_format = TRUE, .frame = .frame)
signal_abort(cnd, .file)

Usefully, though, this also tells me which variable is the problem. It looks as if it's the one where they could enter a free text response, so some of the levels are longer than 120 characters. I could convey this information to the students so that they could temporarily omit this column before exporting - it is likely to not be used in their analysis anyway.

Cheers

Deborah.
DeborahA
Posts: 22
Joined: Tue Apr 14, 2020 11:38 am

Re: Exporting to .sav works but won’t open in SPSS

Post by DeborahA »

Hmm, ok, a further update! I have encountered an instance when saving from the R command line in jamovi works but exporting using the menu causes the same problem (can't open the file in SPSS). So there's something more going on than just the package version of haven.
User avatar
jonathon
Posts: 2627
Joined: Fri Jan 27, 2017 10:04 am

Re: Exporting to .sav works but won’t open in SPSS

Post by jonathon »

> That email address does not seem to be working. Sorry, could you give me an exact email?

oh sorry, we write it contact <at> jamovi.org to reduce the amount of spam we receive :P

you just need to substitute an @ sign where i've written <at> when you put it into your email program.

cheers

jonathon
DeborahA
Posts: 22
Joined: Tue Apr 14, 2020 11:38 am

Re: Exporting to .sav works but won’t open in SPSS

Post by DeborahA »

Hi Jonathon,

Is there any update on this?

Thanks

Deborah.
User avatar
jonathon
Posts: 2627
Joined: Fri Jan 27, 2017 10:04 am

Re: Exporting to .sav works but won’t open in SPSS

Post by jonathon »

sorry for the delay, and thanks for chasing this up ... i've been hindered by having a hard time locating a copy of SPSS at my institution. it becomes harder and harder each year.

i should have access on friday ... let me come back to you then.

jonathon
User avatar
reason180
Posts: 278
Joined: Mon Jul 24, 2017 4:56 pm

Re: Exporting to .sav works but won’t open in SPSS

Post by reason180 »

Perhaps the free, PSPP would be useful for testing purposes, since it does open spss sav files. https://www.gnu.org/software/pspp/
Post Reply