Skip to content

Instantly share code, notes, and snippets.

@jlisic
Created May 27, 2015 02:15
Show Gist options
  • Save jlisic/48e77231d0a5812539a7 to your computer and use it in GitHub Desktop.
Save jlisic/48e77231d0a5812539a7 to your computer and use it in GitHub Desktop.
Convert a sas binary file to a cvs without sas (but with R).
#!/usr/local/bin/Rscript
# get the usual argv
args <- commandArgs(trailingOnly == TRUE)
# get the input sas file name
inFile <- args[1]
# get the output csv file name
inFile <- args[1]
# if the file doesn't exist quit
if (!file.exists( inFile )) {
cat( sprintf("The file %s does not exist."), args[1] )
quit();
}
# load the library
library(sas7bdat)
# write the file out
write.csv(read.sas7bdat(inFile), outFile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment