iefieldkit
iefieldkit copied to clipboard
ietestform : refine test for non valid characters in the field name
Currently the command only allows letters, numbers, underscore and regular spaces in the field name in order to run the command. Here is the code:
gen `illegal_char' = (trim(regexr(`var',"[a-zA-Z0-9_/-]*","")) != "")
Anything else in the field name causes the command to throw an error and not even generate a report. This is because we did have problem with non-regular spaces, see here for more details on non-regular spaces than what most people would like to know.
However, this test might be too strict. The .
is allowed in ODK but not in Stata as a variable name, so that is why this is bad practice, but a .
in the string value will not brake this command so I think it would be better if fields with a .
in the name were just listed in the csv report in a new test instead of causing the command to throw an error.
And there are probably other symbols that are allowed in ODK but not in Stata that should not be included in a field name. @AurelieRi, if you have time the next month, can you come up with a list of more characters that behave like the dot? I am thinking that symbols like #
, :
, ?
etc. could behave the same way.