I am trying to read a Stata .dta file into either python or R so that I can work with it and it is giving me a version error in Python and R . I was wondering how I could resolve this. Here is my code:
import pandas as pd
data = pd.read_stata('file.dta')
Here is the error it is giving me
Traceback (most recent call last):
File "/mnt/c/Users/t/projects/cg/dta_csv.py", line 11, in <module>
data = pd.io.stata.read_stata('file.dta')
File "/home/t/.local/lib/python3.10/site-packages/pandas/io/stata.py", line 2090, in read_stata
return reader.read()
File "/home/t/.local/lib/python3.10/site-packages/pandas/io/stata.py", line 1702, in read
self._ensure_open()
File "/home/t/.local/lib/python3.10/site-packages/pandas/io/stata.py", line 1176, in _ensure_open
self._open_file()
File "/home/t/.local/lib/python3.10/site-packages/pandas/io/stata.py", line 1206, in _open_file
self._read_header()
File "/home/t/.local/lib/python3.10/site-packages/pandas/io/stata.py", line 1288, in _read_header
self._read_old_header(first_char)
File "/home/t/.local/lib/python3.10/site-packages/pandas/io/stata.py", line 1467, in _read_old_header
raise ValueError(_version_error.format(version=self._format_version))
ValueError: Version of given Stata file is 70. pandas supports importing versions 105, 108, 111 (Stata 7SE), 113 (Stata 8/9), 114 (Stata 10/11), 115 (Stata 12), 117 (Stata 13), 118 (Stata 14/15/16),and 119 (Stata 15/16, over 32,767 variables).
I have also trying using R & RStudio with the haven
and foreign
libraries. No luck either
> library(foreign)
> df <- read.dta("file.dta")
Error in read.dta("file.dta") : not a Stata version 5-12 .dta file
> library(haven)
> df <- read.dta("file.dta")
Error in read.dta("file.dta") : not a Stata version 5-12 .dta file
Any suggestion for how I could possibly resolve this?