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_stata() fails to read Stata 14.0 file format #75

Closed
dalewsteele opened this Issue Jun 3, 2015 · 7 comments

Comments

Projects
None yet
3 participants
@dalewsteele
Copy link

dalewsteele commented Jun 3, 2015

When I import the comma delimited file appended at the end, then save using Stata IC 14.0, read_stata fails to parse the resulting .dta file.

Stata code:
import delimited using "ct_race_chd.csv"
save "ct_race_chd.dta", replace
use "ct_race_chd.dta"

Dropbox link to the file created:
https://www.dropbox.com/s/t89lbnlhlm3nslc/ct_race_chd.dta?dl=0

R code:

library(haven)
ct <- read_stata("ct_race_chd.dta")
Error: Failed to parse /home/dsteele/Dropbox/MOOC/ALR/ct_race_chd.dta: Invalid file, or file has unsupported features.

----------------------- ct_race_chd.csv
race,chd,freq
1,1,5
1,0,20
2,1,20
2,0,10
3,1,15
3,0,10
4,1,10
4,0,10

@dalewsteele

This comment has been minimized.

Copy link

dalewsteele commented Jun 4, 2015

If saved in Stata v12 or v13 format, "saveold "ct_race_chd.dta", version(13) "

then haven parses without error

Seems haven is not able to parse Stata v. 14 data files.

@dalewsteele dalewsteele changed the title read_stata() fails to read simple Stata file read_stata() fails to read Stata 14.0 file format Jun 4, 2015

@hadley

This comment has been minimized.

Copy link
Member

hadley commented Jun 5, 2015

@evanmiller is this a known limitation of readstat?

@evanmiller

This comment has been minimized.

Copy link
Contributor

evanmiller commented Jun 5, 2015

It's known now :-).

I previously tried adding support by studying the docs, but I haven't had an actual file to work with until now. I'll report my progress over here:

WizardMac/ReadStat#27

@evanmiller

This comment has been minimized.

Copy link
Contributor

evanmiller commented Jun 5, 2015

Ok, the sample file now opens with ReadStat as of commit WizardMac/ReadStat@bad9575

@dalewsteele

This comment has been minimized.

Copy link

dalewsteele commented Jun 7, 2015

fwiw, Stata provides a detailed description of the .dta format. See:

https://www.dropbox.com/s/2hubfl23b28bsdq/dta_14.pdf?dl=0

@hadley hadley closed this in cd623bb Jun 19, 2015

@hadley

This comment has been minimized.

Copy link
Member

hadley commented Jun 19, 2015

@dalewsteele please try with the dev version, and let us know if it still fails

@dalewsteele

This comment has been minimized.

Copy link

dalewsteele commented Jun 20, 2015

Excellent - the example Stata 14. format file loads fine with latest dev version (haven_0.2.0.9000)

@lock lock bot locked and limited conversation to collaborators Jun 27, 2018

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