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

written dta file not readable in Stata #461

JoWi2 opened this issue Jul 3, 2019 · 6 comments

written dta file not readable in Stata #461

JoWi2 opened this issue Jul 3, 2019 · 6 comments


Copy link

@JoWi2 JoWi2 commented Jul 3, 2019

When writing a .dta file using haven, it can be opened with Stata MP (the most expensive version of Stata with the most features).

I checked with an MWE:

foo <- mtcars #using mtcars with 32 observations of 11 variables
write_dta(foo, "C:/Users/XXXX/Desktop/foo.dta", version = 15) # writing the data frame into a dta file

When opening the file in Stata (the first line - use... - is the Stata command, the rest is basically the error message), I get

use "C:\Users\XXXX\Desktop\foo.dta"
dataset too large
This .dta file format was created by Stata/MP and has more variables than your
Stata can handle.

This is clearly not the case. So if this problem could be resolved in haven, that would be much appreciated!

Copy link

@kuriwaki kuriwaki commented Jul 7, 2019

I get an error as well, but with the following StataMP (version 15.1) error message. Below is the Stata code:

/* mtcars saved in write_dta with version = 14 can be read in by Stata */
use ""

/* but the same thing with version = 15 cannot */
use ""
* .dta file corrupt
* The marker </sortlist> was not found in the file where it was expected to be.  This
*  means that the file was written incorrectly or that the file has subsequently become
* damaged.
* r(688);

Importantly, this only happens when version = 15 in write_dta. I can open the dta fine when version = 14 (the default) or any other version value from 8 to 14.

Copy link

@LulinS LulinS commented Jul 22, 2019

Same errors. Appreciated if it can be solved.

Copy link

@kuriwaki kuriwaki commented Jul 22, 2019

I updated above my comment so the error is reproducible by copy-pasting the snippet into Stata. The online datasets I read from are two that I generated in haven. Hope it helps.

Copy link

@evanmiller evanmiller commented Oct 27, 2019

Thanks for the report. It appears that the integer size of column indexes changed with Stata 15. I'll have a fix of some sort soon.

evanmiller added a commit to WizardMac/ReadStat that referenced this issue Oct 27, 2019
Copy link

@hadley hadley commented Nov 6, 2019

I've updated the version of readstat embedded in haven, so this should be fixed in the development version. Please let me know if not.

@hadley hadley closed this as completed Nov 6, 2019
Copy link

@lock lock bot commented May 5, 2020

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue.

@lock lock bot locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
None yet

No branches or pull requests

5 participants