You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Option relax specifies that the do-file ignore fields in the form that are not in the data; by default, it results in an error. However, it still results in an error for nonexistent fields with problematic (uninsheetable) field names, e.g., those whose Stata names are a duplicate with another field's. Currently option relax writes code to attach char metadata as follows:
local pos : list posof "field_name" in fields
local var : word `pos' of `all'
capture confirm variable `var', exact
if _rc ///
local formnotdata `formnotdata' `var'
else {
char commands...
}
Yet if `pos' == 0, :word results in an error:
. local var : word `pos' of `all'
invalid syntax
r(198);
Thus, the code should look more like:
local pos : list posof "field_name" in fields
if !`pos' ///
local found 0
else {
local var : word `pos' of `all'
capture confirm variable `var', exact
local found = !_rc
}
if !`found' ///
local formnotdata `formnotdata' `var'
else {
char commands...
}
The following also works. It's slightly less clean, as it adds an extra capture, but it's fine as a way to facilitate an easier find/replace for those wanting an immediate fix.
local pos : list posof "field_name" in fields
capture local var : word `pos' of `all'
if !_rc ///
capture confirm variable `var', exact
if _rc ///
local formnotdata `formnotdata' `var'
else {
char commands...
}
On a final note, we shouldn't add `var' to `formnotdata' but rather the field name.
The text was updated successfully, but these errors were encountered:
I think we may simply remove option relax in a future version, as it makes the code more complex and adds maintenance costs, and it shouldn't be needed when the submission data is compatible with the ODK Briefcase format (see #46).
Option
relax
specifies that the do-file ignore fields in the form that are not in the data; by default, it results in an error. However, it still results in an error for nonexistent fields with problematic (uninsheet
able) field names, e.g., those whose Stata names are a duplicate with another field's. Currently optionrelax
writes code to attachchar
metadata as follows:Yet if
`pos' == 0
,:word
results in an error:Thus, the code should look more like:
The following also works. It's slightly less clean, as it adds an extra
capture
, but it's fine as a way to facilitate an easier find/replace for those wanting an immediate fix.On a final note, we shouldn't add
`var'
to`formnotdata'
but rather the field name.The text was updated successfully, but these errors were encountered: