I have a dataset with a large number of variables (500+) and I am just realizing now that for many (possibly all?) string variables, what look like normal missings actually have a 'hidden' space (" "). I know the basic solution is quite simple:
Code:
replace FL2A_w2 = subinstr(FL2A_w2, " ", "", .)
But, I'm wondering how to best handle this with such a large number of variables that I need to do this for. I tried this:

Code:
foreach var of varlist _all {
replace `var' = subinstr(`var', " ", "", .)
}
But with that, I get a type mismatch error, I assume due to the fact that some of my variables in my dataset are not strings.

Any ideas on the best way to handle this? Thank you much!