Export R file to spss dataset

Hi everyone,

I want to make changes to a dataset in R (e.g. computing new variables) and then export it to SPSS, but I don't know if this is possible. I found a youtube video and followed the instructions, but the result was a very messy dataset that was completely useless. Any tips?

Thank you!

Try the {haven} example

write_sav(mtcars, "mtcars.sav")

to see how that carries over into your SPSS environment. It's a solid package from Hadley Wickham, himself. I don't have a SPSS set-up, but I'd be extremely surprised if the example didn't work.

However, depending on what your use case writes to SPSS, I suppose it's possible that there could be a glitch. What I'd suggest is to test by creating a SPSS object, using read_sav to bring it into R, then simply change some value and write back. If that works, then the next step would be to see if the code being used in your problem creates any components that require more modification to be well-formed in SPSS. If you need more help, please come back with a reprex. See the FAQ: How to do a minimal reproducible example reprex for beginners.

Thank you very much!

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.