Skip to content

Instantly share code, notes, and snippets.

@igorbrigadir
Created March 1, 2016 18:32
Show Gist options
  • Save igorbrigadir/0d03171e3e731b615f55 to your computer and use it in GitHub Desktop.
Save igorbrigadir/0d03171e3e731b615f55 to your computer and use it in GitHub Desktop.
Convert SPSS SAV or DTA files to CSV with R
library(foreign)
# SAV file?
write.table(read.spss("spss_data.sav", file="from_sav_data.csv", quote = FALSE, sep = ",")
# DTA file?
write.table(read.dta("spss_data.dta"), file="from_dta_data.csv", quote = FALSE, sep = ",")
@yaoyang33
Copy link

Line 4 should be

write.table(read.spss("spss_data.sav"), file="from_sav_data.csv", quote = FALSE, sep = ",")

You missed a bracket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment