I am working with a number of large datasets which have had value labels applied inappropriately. As part of an automated solution to deal with this, I need to generate a list of all variables (in this example a local called "mislabelled") which contains the name of all variables which have the value label "bad_label".
Code:
local mislabelled
foreach v of varlist _all {some_command `v'if ("`r_somecommand'"=="bad_label"){
[INDENT=2]local mislabelled "`mislabelled'" "`v'"[/INDENT]}
}

Comment