Unable to open stata files
Unable to open stata files
Hello!
I'm using jamovi desktop version 2.3.26.0 and I want to import stata files, but when I try to do it, i get an error:
"Unable to open tuple index out of range"
What may be causing this?
Thanks in advance!
I'm using jamovi desktop version 2.3.26.0 and I want to import stata files, but when I try to do it, i get an error:
"Unable to open tuple index out of range"
What may be causing this?
Thanks in advance!
Re: Unable to open stata files
Hey @neck_dvvp,
this looks like a Python msg.
It might be that you need to update your version of jamovi.
We are currently with 2.3.28 solid and 2.4.1 current.
However if you don't mind providing your Stata file I might take a look.
Cheers,
Maurizio
this looks like a Python msg.
It might be that you need to update your version of jamovi.
We are currently with 2.3.28 solid and 2.4.1 current.
However if you don't mind providing your Stata file I might take a look.
Cheers,
Maurizio
Re: Unable to open stata files
Hi!
Thanks for the quick answer.
I updated my jamovi to version 2.3.28 and I get the same error.
Sorry but I can't provide my stata file. But i tried it with multiple stata files, all getting the same error. I also tried to open data via open and special import, with no changes.
Edit: I now tried with other files and it worked, it may be file specific, but what could cause this? The file opens in R and SPSS, just not jamovi
Thank you
Thanks for the quick answer.
I updated my jamovi to version 2.3.28 and I get the same error.
Sorry but I can't provide my stata file. But i tried it with multiple stata files, all getting the same error. I also tried to open data via open and special import, with no changes.
Edit: I now tried with other files and it worked, it may be file specific, but what could cause this? The file opens in R and SPSS, just not jamovi
Thank you
Re: Unable to open stata files
Yes, I see!
So, since you know and use R, I'd suggest you try this:
Code: Select all
require(jmvReadWrite)
jmvReadWrite::convert_to_omv(fleInp = 'x:/Stata17/dta/auto.dta', fleOut = 'x:/jamovi/omv/auto.omv')
my_omv <- jmvReadWrite::read_omv(fleInp = 'x:/jamovi/omv/auto.omv')
head(my_omv)
You can download it from CRUN or Sebastian's repository here:
https://github.com/sjentsch/jmvReadWrite
I think it's superfluous to remind you to replace in the code, path and name of my file with yours, but I do .
let me know what happens.
Cheers,
Maurizio
Re: Unable to open stata files
Well, I wanted to give you good news, but that only fixed 3 of my files (which is already a starting point). The other 3 can't be converted, with the error message:
I tried changing the usePkg argument to haven, which is what I was using originally in R, and it still did not work. All files have the same structure so I really don't understand what is happening.
Thank you for letting me know of that R package, it seems super useful!
Code: Select all
The warning was: unable to translate '<stata_dta><header><release>118</release><byteorder>LSF</byteorder><K>[</K><N><b4>' to a wide string
Error in chkDtF(dtaFrm) :
Input data are either not a data frame or have incorrect (only one or more than two) dimensions.
Thank you for letting me know of that R package, it seems super useful!
Re: Unable to open stata files
This tells us that it is .dta 118 format.neck_dvvp wrote: ↑Wed Jul 19, 2023 9:20 amCode: Select all
The warning was: unable to translate '<stata_dta><header><release>118</release><byteorder>LSF</byteorder><K>[</K><N><b4>' to a wide string
It went into effect with Stata 14 and is known as .dta Format 118.
It is also the primary format used by Stata 15 through Stata 18.
For datasets with more than 32,767 variables, Stata 15 through Stata 18 uses a slightly different format (the 119).
There are differences between operating systems, especially Win versus Mac or Linux.
Your files that don't pass are from which version of Stata with which operating system?
Have you tried adding encoding = "UTF-8" or encoding = "Latin1" inside the read_dta() function to tell R to import the same data without encoding it into numbers.
What happens with this code:
Code: Select all
require(jmvReadWrite)
require(rio)
my_dta <- rio::import("x:/Stata17/dta/auto.dta")
jmvReadWrite::write_omv(dtaFrm=my_dta, fleOut = 'x:/jamovi/omv/auto.omv')
my_omv <- jmvReadWrite::read_omv(fleInp = 'x:/jamovi/omv/auto.omv')
head(my_omv)
Cheers,
Maurizio
Re: Unable to open stata files
Hello again!
Thank you so much for all the help!
Unfortunately I have no idea which Stata version these files are from, nor do I know which OS they were using. In theory, they should all have the same format and version, hence all my doubts.
Anyways, with the last code snippet you provided I was able to open every file successfully! Thank you so much!
I wish you the best
Thank you so much for all the help!
Unfortunately I have no idea which Stata version these files are from, nor do I know which OS they were using. In theory, they should all have the same format and version, hence all my doubts.
Anyways, with the last code snippet you provided I was able to open every file successfully! Thank you so much!
I wish you the best
Re: Unable to open stata files
Hei,
the only other suggestion I could possibly make is to open the respective files in Stata and to save it in a non-Stata-format: I never used Stata, so I don't know what export options are provided, but ideally sth. that R could read directly (i.e., RData, rds - if you want to keep some metadata - or CSV since that can be read by any software). This wouldn't be as easy as mass conversion using convert_omv, but would likely help you to import at least most of the data (missing some metadata such as labels, etc.).
The only other option you may try is readstata13 (https://cran.r-project.org/package=readstata13). I don't know to what degree it is using the same codebase as haven / ReadStat, but it may be worth a shot. You would need to adjust Maurizios R-code for that purpose.
It typically is impossible to do debugging without having data files to try out. However, in your case, the problem happens already when reading the file. That means, I anyway only would have had a very slight chance to solve your problem: What jmvReadWrite does is (primarily) to read and write jamovi-files (reading foreign formats is more for convenience, and relies on R-packages that I am not involved in).
Best regards, Sebastian
the only other suggestion I could possibly make is to open the respective files in Stata and to save it in a non-Stata-format: I never used Stata, so I don't know what export options are provided, but ideally sth. that R could read directly (i.e., RData, rds - if you want to keep some metadata - or CSV since that can be read by any software). This wouldn't be as easy as mass conversion using convert_omv, but would likely help you to import at least most of the data (missing some metadata such as labels, etc.).
The only other option you may try is readstata13 (https://cran.r-project.org/package=readstata13). I don't know to what degree it is using the same codebase as haven / ReadStat, but it may be worth a shot. You would need to adjust Maurizios R-code for that purpose.
It typically is impossible to do debugging without having data files to try out. However, in your case, the problem happens already when reading the file. That means, I anyway only would have had a very slight chance to solve your problem: What jmvReadWrite does is (primarily) to read and write jamovi-files (reading foreign formats is more for convenience, and relies on R-packages that I am not involved in).
Best regards, Sebastian
Re: Unable to open stata files
if you create an issue on our issues page, attaching the problematic files, we can take a look:
https://github.com/jamovi/jamovi/issues
jonathon
https://github.com/jamovi/jamovi/issues
jonathon