Analyzing Odk Collected data with Stata

Hello odk users!
I am using odk collect v1.11.1, I have created a xlsform with survey and choices which is running well in my android and I have collected my data then uploaded to odk.ona.io.

After downloading the form and trying to link and execute on stata using a dofile it brings any error "type mismatch"

Is name a string variable? . is a numeric missing value, so if name is string, that means that name and . have different types. The string missing value is "", the empty string. That means your drop command could be:

drop if name == ""

For more information on missing values in Stata, type help missing in Stata.

In case you haven't come across it, I also wanted to mention odkmeta, a Stata user-written command to import ODK data to Stata using the metadata from the survey and choices worksheets of the XLSForm. (I'm an author of odkmeta.) If you export your data from Ona using Briefcase, you should then be able to import that data to Stata using odkmeta. To install odkmeta, type ssc install odkmeta in Stata, then type help odkmeta to read the help file.

3 Likes

You should use STATA do file for this write down your syntax in do file and then run it.

1 Like

Thanks for contribution Sir!
name is not a string variable it is a text.

Also I have the interest to know more about that odkmeta I managed to install it but the odk briefcase failed to pull the file from ona and below is the details of the error
error 1

If possible can I upload the full code of my do file? so as you can help me to know the source of error

name may be a text field in ODK, but in Stata, such fields are imported as string variables: ODK and Stata have different type systems. Stata has two basic data types: string and numeric. From the Stata help files:

Each element of data is said to be either type numeric or type string.

Within those two basic data types, Stata then has several numeric data types and many string data types.

To view the data type of name, type describe name in Stata. If the type begins with str (for example, str50 or strL), that means it's string.

If name is string, you should be able fix the error by replacing the numeric missing value . with the string missing value "". Stata does not allow you to compare a string value with a numeric value, or vice versa.

The Ona URL you enter in Briefcase should not have a forward slash at the end. Rather than https://odk.ona.io/tmhalila/, enter https://odk.ona.io/tmhalila.

Hope that helps!