ODK Meta using Stata

Hi everyone

I am facing issues with ODK Meta command in STATA. After downloading the CSV file from ODK Central and i try to read my CSV file using ODK Meta, i encounter this error "time variable stinttime could not be converted using the mask hms" The mask format in ODK meta is local timemask hms and my data for stinttime appears as "13:39:00.000+03:00", "12:55:00.000+03:00" in the CSV . How do i go about this error

From my recent experience, you are most likely to encounter this error. What I did to circumvent it is that I marked the "*Date and time variables" block as comment and then handled the dates in my own way using string functions.

Thank you so much @KennyAto . I will explore this as i continue to search for other options

Hi @Makanga,
The odkmeta version is a bit old and was seemingly composed at the time of ODK aggregate where by most extraction was done using the briefcase. I think this is why the do file generated by odkmeta does not recognise the timemask, but also the datatimemask for the Submmision date.
Currently, the csv files in the exported zip from central have detailed time variables (e.g., now()) with date, hh, mm, ss, micro ss, and even leap ss.

I agree with @KennyAto idea to comment out lines calling for them in the do file so they're retained as strings and can do some of the following e.g., if its stat_t ;

split stat_t, g(start) p("T")
split start2, g(start_time) p("+")
drop start1 start2 start_time2
g start_time= clock(start_time1, "hms")
format start_time %tchh:MM:SS_AM
order start_time, a(stat_t)

With your string format mentioned as "13:39:00.000+03:00", "12:55:00.000+03:00" - you can ignore the first line above. If exported the zip, that will be the format.

  • date time variables
  • SubmissionDate // has a different string qualifier, Z in latest ODK clients - ODK collect this time to isolate time zone for server/central based time settings; "T" remains common to start_time and end_time
    So for all date, variables, you can strip Submission data of 'Z' and put them in a loop such as;

replace SubmissionDate= subinstr(SubmissionDate,"Z","",1)

local datetimemask YMDhms

foreach var of varlist stat_t end_time SubmissionDate{
replace `var'= subinstr(`var',"T"," ",1)
replace `var'= subinstr(`var',"+03:00","",1)

tempvar temp

		generate double `temp' = Clock(`var', "`datetimemask'")
		format `temp' %tcMon_dd,_CCYY_hh:MM:SS_AM
		move `temp' `var'

		drop `var'
		rename `temp' `var'

}

1 Like