Odkmeta error in stata: invalid stub varname

Hi ODK Community,
I am Mónica Vargas and I work in a non-profit-organization in Mexico named "Que funciona para el desarrollo". We have been using the ODK server to collect our surveys and the "odkmeta" stata program to clean them. Unfortunately, we haven't been able to run the import do file since the error "invalid stub cdp" (cdp is my variable) comes up.

We have 3 variables starting with cdp:
cdp cdp2 and cdp3 are required and "select_multiple" type variables which have a constraint (not(selected(.,'0') and count-selected(.)>1)). Each cdp* variable have about 5 questions which are relevant depending on the answer of cdp*.

We would like to solve this problem as soon as possible but we don't know how.
Your inputs on the matter would be truly appreciated.

Hi Mónica,

What was the command that issued the error message you saw? It can be tricky to debug Stata errors, and the more context, the better. You could try pasting the last few lines of the Results window here.

From what you've described, it sounds like it could be an issue with the split command. odkmeta splits select_multiple variables using split. However, as the odkmeta help file notes:

split will result in an error if a select_multiple variable has a long name or if splitting it would result in duplicate variable names.

I think that's what's happening here. Splitting cdp will result in variables cdp1 cdp2 cdp3 .... However, cdp2 and cdp3 already exist as separate variables, hence the error.

To resolve this, I would read the section of the help file entitled "Remarks for field names." There's a section in the do-file that's designated for manually renaming variables that are problematic for split. One option would be to rename cdp as cdp1 so that it is split as cdp1_1 cdp1_2 cdp1_3 ... rather than cdp1 cdp2 cd3 ....

If it turns out to be more complicated than that, you may need to reach out to Innovations for Poverty Action directly. CC @Lindsey_Shaughnessy

Hope that helps!



Thanks so much for the information it was very helpful! I renamed the
variables and the do file was able to run further down but I encountered a
new problem. A new error has come up saying "Unexpected values
encountered:" (r(459)) followed by the 74 farmers IDs´ who answered the
survey. The ID are constructed by three pairs of numbers which are divided
by dots. For example, .21.02.01.
This is the first time we have had problem with the do file.
Could you help us solve it?

I was able to solve the problem. I had two variables with the IDs so I
eliminated one and the error did not come up.
Thanks so much!!!

1 Like

2 posts were split to a new topic: How to use odkmeta