# How to export to a dta file?

**URL:** https://discourse.julialang.org/t/how-to-export-to-a-dta-file/29975
**Category:** New to Julia
**Tags:** question
**Created:** [October 16, 2019, 8:42am UTC](https://discourse.julialang.org/t/how-to-export-to-a-dta-file/29975 "2019-10-16T08:42:31Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![drarnau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drarnau/32/4476_2.png) [@drarnau](https://discourse.julialang.org/u/drarnau)
#### Post date: [October 16, 2019, 8:42am UTC](https://discourse.julialang.org/t/how-to-export-to-a-dta-file/29975/1 "2019-10-16T08:42:31Z")

</div>

Dear all,

I simulate a model in Julia (think of some sort of Monte Carlo experiment) and I want to export the data generated by the model to Stata (.dta format). What is the best way to do it?

Ideally, I’d like to avoid using a CSV.

Thanks!

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [October 16, 2019, 8:45am UTC](https://discourse.julialang.org/t/how-to-export-to-a-dta-file/29975/2 "2019-10-16T08:45:53Z")

</div>

> License: Proprietary

good luck, [WIP Add write support by davidanthoff · Pull Request #42 · queryverse/ReadStat.jl · GitHub](https://github.com/queryverse/ReadStat.jl/pull/42)

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [October 16, 2019, 8:48am UTC](https://discourse.julialang.org/t/how-to-export-to-a-dta-file/29975/3 "2019-10-16T08:48:39Z")

</div>

I have written

[https://github.com/tpapp/StataDTAFiles.jl](https://github.com/tpapp/StataDTAFiles.jl)

but writing is not implemented. PRs welcome.

That said, I would just write CSV and read it in Stata unless your data is huge.

---

<div class="post-metadata">

### Author: ![drarnau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drarnau/32/4476_2.png) [@drarnau](https://discourse.julialang.org/u/drarnau)
#### Post date: [October 16, 2019, 8:50am UTC](https://discourse.julialang.org/t/how-to-export-to-a-dta-file/29975/4 "2019-10-16T08:50:39Z")

</div>

Thanks!

Yeah, I think I’ll have to use CSV but I was wondering if there is something better out there.

Look forward to use your package.

---

<div class="post-metadata">

### Author: ![drarnau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drarnau/32/4476_2.png) [@drarnau](https://discourse.julialang.org/u/drarnau)
#### Post date: [October 16, 2019, 8:51am UTC](https://discourse.julialang.org/t/how-to-export-to-a-dta-file/29975/5 "2019-10-16T08:51:11Z")

</div>

There seems to be functionality to read but not to write to .dta.

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [October 16, 2019, 8:54am UTC](https://discourse.julialang.org/t/how-to-export-to-a-dta-file/29975/6 "2019-10-16T08:54:28Z")

</div>

that’s why it’s a [WIP] (work in progress)

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [October 16, 2019, 8:56am UTC](https://discourse.julialang.org/t/how-to-export-to-a-dta-file/29975/7 "2019-10-16T08:56:30Z")

</div>

> [@drarnau](#):
>
> Look forward to use your package.

As I said, writing would need to be implemented. It is fairly straightforward, except for the need to go back and do the offsets. The README of my package contains links documenting the format.

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [October 16, 2019, 12:28pm UTC](https://discourse.julialang.org/t/how-to-export-to-a-dta-file/29975/8 "2019-10-16T12:28:42Z")

</div>

In the meantime, I would recommend using Rcall.jl and using the `haven` package maintained by tidyverse.
