Is there a way to convert a dta
file to a csv
?
I do not have a version of Stata installed on my computer, so I cannot do something like:
File --> "Save as csv"
Just open the . dta file in Stata and then export it as an Excel/CSV file (File >> Export >> Data to Excel spreadsheet(. xls)/Text data (delimited, . csv).
Double-click on a Stata data file, which is a file whose extension is . dta. Note: The file extension may not be visible, depending on what options you have set in your operating system. Select File > Open... or click on the Open button and navigate to the file.
The Stata_dta format (with extension . dta) is a proprietary binary format designed for use as the native format for datasets with Stata, a system for statistics and data analysis. Stata 1.0 was released in 1985 for the IBM PC. Stata is now available for Windows, Mac OS, and Unix.
The frankly-incredible data-analysis library for Python called Pandas
has a function to read Stata files.
After installing Pandas
you can just do:
>>> import pandas as pd >>> data = pd.io.stata.read_stata('my_stata_file.dta') >>> data.to_csv('my_stata_file.csv')
Amazing!
You could try doing it through R:
For Stata <= 15 you can use the haven package to read the dataset and then you simply write it to external CSV file:
library(haven) yourData = read_dta("path/to/file") write.csv(yourData, file = "yourStataFile.csv")
Alternatively, visit the link pointed by huntaub in a comment below.
For Stata <= 12 datasets foreign package can also be used
library(foreign) yourData <- read.dta("yourStataFile.dta")
You can do it in StatTransfer, R or perl (as mentioned by others), but StatTransfer costs $$$ and R/Perl have a learning curve.
There is a free, menu-driven stats program from AM Statistical Software that can open and convert Stata .dta from all versions of Stata, see:
http://am.air.org/
I have not tried, but if you know Perl you can use the Parse-Stata-DtaReader module to convert the file for you.
The module has a command-line tool dta2csv, which can "convert Stata 8 and Stata 10 .dta files to csv"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With