SPSS .sav to CSV

In attempting to download some data from the UK Data Service, I ended up having to use a file created by the statistics package SPSS. I don't have SPSS, nor have I ever used it, and these .sav files don't seem to open up sensibly in a text editor.

Fortunately, R has come to my rescue! What follows are the steps I took in Debian linux to get a comma separated values (CSV) file out, which can be opened by Excel, text editors and lots of other programs.

To install R, you do:

sudo apt-get install r-base

Then you open up R by typing "R". Once you're in, install and start the "foreign" package for handling SPSS files:


Then you can read in the data set as a data frame:

dataset1 = read.spss('/path/to/file.sav', to.data.frame=TRUE)

Then all that remains is to output the CSV file. I saved mine in /home/beth:

write.csv(dataset1, file='/home/beth/dataset1.csv')