Skip to content

Instantly share code, notes, and snippets.

@martjanz
Created October 2, 2015 02:08
Show Gist options
  • Save martjanz/c483ec24adb5e455ab6e to your computer and use it in GitHub Desktop.
Save martjanz/c483ec24adb5e455ab6e to your computer and use it in GitHub Desktop.
SAV2CSV Converter
library(memisc)
filenames <- data.frame(c('CPV2010', 'PROV', 'DPTO', 'FRAC', 'RADIO', 'VIVIENDA', 'HOGAR', 'PERSONA'),
c('censo', 'provincias', 'departamentos', 'fracciones', 'radios', 'viviendas',
'hogares', 'personas'))
names(filenames) <- c('sav', 'csv')
sav2csv <- function(x) {
savname <- x[1]
csvname <- x[2]
data <- as.data.set(spss.system.file(paste(savname, '.sav', sep = "")))
write.csv(data, paste(csvname, '.csv', sep = ''), row.names = FALSE)
}
apply(filenames, 1, sav2csv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment