Convert a dta file to csv without Stata software

前端 未结 11 2055

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: <

相关标签:
11条回答
  • 2020-11-30 22:24

    Some mentioned SPSS, StatTransfer, they are not free. R and Python (also mentioned above) may be your choice. But personally, I would like to recommend Python, the syntax is much more intuitive than R. You can just use several command lines with Pandas in Python to read and export most of the commonly used data formats:

    import pandas as pd

    df = pd.read_stata('YourDataName.dta')

    df.to_csv('YourDataName.csv')

    0 讨论(0)
  • 2020-11-30 22:25

    SPSS can also read .dta files and export them to .csv, but that costs money. PSPP, an open source version of SPSS, which is rough, might also be able to read/export .dta files.

    0 讨论(0)
  • 2020-11-30 22:26

    StatTransfer is a program that moves data easily between Stata, Excel (or csv), SAS, etc. It is very user friendly (requires no programming skills). See www.stattransfer.com

    If you use the program just note that you will have to choose "ASCII/Text - Delimited" to work with .csv files rather than .xls

    0 讨论(0)
  • 2020-11-30 22:35

    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")
    
    0 讨论(0)
  • 2020-11-30 22:37

    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!

    0 讨论(0)
提交回复
热议问题