Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read_sas fails on compressed sas7bdat files #31

Closed
ajdamico opened this issue Mar 3, 2015 · 4 comments
Closed

read_sas fails on compressed sas7bdat files #31

ajdamico opened this issue Mar 3, 2015 · 4 comments

Comments

@ajdamico
Copy link
Contributor

ajdamico commented Mar 3, 2015

hey boss, thanks for all your hard work. here's a reproducible example

# read_sas() fails on compressed .sas7bdat files
    # and gives an unhelpful error message
# read.sas7bdat() also fails, but explains why
# read.sas7bdat.parso succeeds


# load a few packages to demonstrate successes and failures
library(haven)
library(sas7bdat)
library(devtools)
install_github( "biostatmatt/sas7bdat.parso" )
library(sas7bdat.parso)

# initiate some temporary files
tfp <- tempfile() ; tff <- tempfile() ; tfh <- tempfile()

# three of the latest files from the us census bureau's current population survey
# the current population survey is the major federal benchmark for employment, poverty, and health insurance in the united states

download.file( "http://www.census.gov/housing/extract_files/data%20extracts/cpsasec14/pppub14_redes.sas7bdat" , tfp , mode = 'wb' )
download.file( "http://www.census.gov/housing/extract_files/data%20extracts/cpsasec14/ffpub14_redes.sas7bdat" , tff , mode = 'wb' )
download.file( "http://www.census.gov/housing/extract_files/data%20extracts/cpsasec14/hhpub14_redes.sas7bdat" , tfh , mode = 'wb' )

# breaks
havenp <- read_sas( tfp )
# works
havenf <- read_sas( tff )
# breaks
havenh <- read_sas( tfh )

# breaks
sbdp <- read.sas7bdat( tfp )
# breaks
sbdf <- read.sas7bdat( tff )
# breaks
sbdh <- read.sas7bdat( tfh )

# works
parsop <- read.sas7bdat.parso( tfp )
# works
parsof <- read.sas7bdat.parso( tff )
# works
parsoh <- read.sas7bdat.parso( tfh )

# more reading about sas7bdat.parso here
# http://biostatmatt.com/archives/2618
@ajdamico
Copy link
Contributor Author

ajdamico commented Mar 4, 2015

quick note: read.sas7bdat.parso does not work either
BioStatMatt/sas7bdat.parso#5

@evanmiller
Copy link
Collaborator

Depends on WizardMac/ReadStat#21

@evanmiller
Copy link
Collaborator

Fixed in WizardMac/ReadStat@69d5751 and WizardMac/ReadStat@8c0463a

@hadley if you update to the latest ReadStat code you should be able to close this issue.

@scvega
Copy link

scvega commented Jun 18, 2015

HI there, In trying to read_sas files, I am getting the "A row in the file was not the expected length." (it happens for all my SAS files) so after looking up, I follow the instructions here (and on the intro page) attempting to update to the latest ReadStat code. I now get the following:
Warning messages:
1: running command 'wget "https://github.com/WizardMac/ReadStat/archive/master.zip" -O "C:\Users\Silvia\AppData\Local\Temp\Rtmpi0gQKP\file1f0823635f9b"' had status 127
2: In download.file("https://github.com/WizardMac/ReadStat/archive/master.zip", :
download had nonzero exit status

Read the git use's manual, and I do see that the problem might be in wget. any suggestions on where to go from here?

I have spent a lot of time with these functions because I have a full library of SAS datasets that are too big to just dump into text files and read into R. Thanks for putting together the Haven library.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants