worldbank / iefieldkit

Stata commands designed for Impact Evaluations field work. These are tools that are used during/after a survey in the field for data quality monitoring.
MIT License
38 stars 18 forks source link

iecorrect: command breaks if ID with correction in `apply` contains `-` #240

Closed kbjarkefur closed 1 year ago

kbjarkefur commented 1 year ago

It is not possible to use iecorrect apply if the ID used in the excel sheet contains hyphens -.

Here is a reproducible example:

sysuse auto, clear
replace make = subinstr(make, "Datsun ", "datsun-",  .)
iecorrect apply using "C:\Users\wb462869\Downloads\hyphen-id.xlsx" , idvar(make)

and use the file hyphen-id.xlsx from here: hyphen-id.xlsx.

I get an error that seems to be from the if-condition generated in the program _idcond and used in _donumeric on this line: https://github.com/worldbank/iefieldkit/blob/eb2ee624ddd20a42ff8a1aca647cc7cf28d35f0c/src/ado_files/iecorrect.ado#L1124

It seems like the line brakes on the hyphen in (make == "datsun-210") & "' such that it is trying to run a line of code that is 210") & "'.