Hello Community,
I am not having success generating an import.do file with a repeat function. I get the following error message when it comes to the merge:
- Merge repeat groups.
.
. * mKr1
.
. use THRIVE_TANZ_HH_EL_LIVE_Sunday_nomVC_norepeat-mK-mKr1, clear
.
. * Rename any variable names that are difficult for -merge- or -reshape-.
. // rename ...
.
. drop KEY SETOFmKr1
variable SETOFmKr1 not found
r(111);
choices.csv (51.0 KB) survey.csv (376.7 KB)
Any help is greatly appreciated!
Vicki
Hi @VickiBrown!
How did you download the data? Did you use ODK Briefcase or download the CSV .zip from ODK Central?
Also, could you send some fake data (either attaching here or sending me a direct message)?
I tried running the do-file on the data and was able to reproduce the error. The issue is that while ODK Central exports data in a format very similar to ODK Briefcase, it does not generate SET-OF
columns. In general, those SET-OF
columns aren't particularly useful; odkmeta
just uses them to order variables. And actually, I realized that we have previously discussed changing how odkmeta
handles SET-OF
variables. I'm not sure when, but I do think we'll want to make that change to odkmeta
at some point.
For now, you could use ODK Briefcase to download the data (which will have SET-OF
columns), or you could make a few changes to the do-file.
To change the do-file, first remove the char
commands for the SET-OF
variables. (I think you've maybe done this already?) Next, remove the reference to the SET-OF
variable in this drop
command:
drop KEY SETOFmKr1
Next, a SET-OF
variable is used to order the variables after the merge. You can choose a different variable for that purpose and also remove the drop
that follows:
unab after : _all
local new : list after - before
foreach var of local new {
move `var' SETOFmKmKr1 mkk3
}
drop SETOFmKmKr1
Let me know if that works!
1 Like
Hi Matt,
Thank you so much for the clarification, this is extremely helpful!
Cheers,
Vicki
1 Like
Just wanted to say that changing the import do file has solved this SETOF issue for me.
If there is a more current version of ODK Meta or a more current way of importing ODK data from Central into Stata, please do let me know.
Otherwise, I just wanted to say that I appreciate this thread. It has helped me a lot!
1 Like