# Errors parsing when reading STATA file

**URL:** <https://discourse.julialang.org/t/errors-parsing-when-reading-stata-file/30840>\
**Category:** General Usage\
**Created:** [November 7, 2019, 6:12pm UTC](https://discourse.julialang.org/t/errors-parsing-when-reading-stata-file/30840 "2019-11-07T18:12:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [November 7, 2019, 6:12pm UTC](https://discourse.julialang.org/t/errors-parsing-when-reading-stata-file/30840/1 "2019-11-07T18:12:54Z")

</div>

I am reading a STATA file (likely created in 2014; not known which STATA version was used) and get the following error:

```julia
using DataFrames
[Info: Precompiling DataFrames [a93c6f00-e57d-5684-b7b6-d8193f3e46c0]

julia> using StatFiles
[Info: Precompiling StatFiles [1463e38c-9381-5320-bcd4-4134955f093a]

julia> df = DataFrame(load("/Users/lutz/Documents/projects/p2018/migrant_wage_gains/MAFE_data/Ghana/Stata/gh_qb_migration_140417.dta"));
ERROR: Error parsing /Users/lutz/Documents/projects/p2018/migrant_wage_gains/MAFE_data/Ghana/Stata/gh_qb_migration_140417.dta: 17
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] parse_data_file!(::ReadStat.ReadStatDataFrame, ::Ptr{Nothing}, ::String, ::Type{Val{:dta}}) at /Users/lutz/.julia/packages/ReadStat/JnXAZ/src/ReadStat.jl:266
 [3] read_data_file(::String, ::Type) at /Users/lutz/.julia/packages/ReadStat/JnXAZ/src/ReadStat.jl:237
 [4] read_dta at /Users/lutz/.julia/packages/ReadStat/JnXAZ/src/ReadStat.jl:274 [inlined]
 [5] getiterator(::StatFiles.StatFile) at /Users/lutz/.julia/packages/StatFiles/gxVDC/src/StatFiles.jl:57
 [6] nondatavaluerows(::StatFiles.StatFile) at /Users/lutz/.julia/packages/Tables/FXXeK/src/tofromdatavalues.jl:16
 [7] columns at /Users/lutz/.julia/packages/Tables/FXXeK/src/fallbacks.jl:177 [inlined]
 [8] #DataFrame#412(::Bool, ::Type{DataFrame}, ::StatFiles.StatFile) at /Users/lutz/.julia/packages/DataFrames/yH0f6/src/other/tables.jl:32
 [9] DataFrame(::StatFiles.StatFile) at /Users/lutz/.julia/packages/DataFrames/yH0f6/src/other/tables.jl:23
 [10] top-level scope at REPL[9]:100: 

```

The file contains 2,000 rows and about 100 variables of mixed types (including strings). The data are confidential, so I cannot post the file.

I’m on Julia 1.2, MacOS Catalina.

Stat/Transfer 14 has no problem reading the file and converting it to Excel.

Any suggestions on working around this would be appreciated.

---

<div class="post-metadata">

**Author:** ![jmboehm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmboehm/32/2263_2.png) [@jmboehm](https://discourse.julialang.org/u/jmboehm)\
**Post date:** [November 7, 2019, 6:35pm UTC](https://discourse.julialang.org/t/errors-parsing-when-reading-stata-file/30840/2 "2019-11-07T18:35:08Z")

</div>

If other Stata files work fine, then it’s likely an issue in the [ReadStat library](https://github.com/WizardMac/ReadStat), which ReadStat.jl wraps. I’ve experienced the same error message with certain Stata files. Try opening the file in a recent Stata and saving it in an older Stata format (`saveold`), that has usually worked for me.

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [November 7, 2019, 7:11pm UTC](https://discourse.julialang.org/t/errors-parsing-when-reading-stata-file/30840/3 "2019-11-07T19:11:21Z")

</div>

Thanks - I took the opposite approach - save it in V15; it worked.
