I lost access to my Stata license and need to edit some.dta files for a school project. I've already tried the solutions in this post and this post , but I keep getting error messages saying that they're not Stata 5-12 files (in R) and that they're not Stata 11-15 files (in Python). Is there a way to open Stata 16.dta files in either R or Python and edit them? If editing's not possible, is there a way to at least convert them into a.csv or.xslx?
In Python:
# Import data
import pandas as pd
df = pd.read_stata('filename.dta')
# Possibly edit the DataFrame here
# Save as dta
df.to_stata('filename.dta', write_index=False)
# Save as csv
df.to_csv('filename.csv', index=False)
R
To import:
# install.packages("rio")
data <- rio::import("file.dta")
To export:
rio::export(data, "file.xlsx") # or .csv or a few other formats
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.