Hello,

I am sorry if this is something simple I am missing, and thank you in advance for your thoughts. I have a data set with 50+ variables, and I want to destring 20 of those variables and do not want to do anything to the other variables. When I destring, I also need to ignore(".,"). So I am attempting to write a simple foreach loop and limit this to the 20 variable columns. I have tried multiple different ways of writing this code, but every way I write the foreach loop it cycles through all variables in my data set (which I do not want). Here are some examples of the foreach code attempts I have made. (the varlist is u1 - u20). For some reason every way I attempt this Stata runs through every column and does the operation which is in brackets. I think I must be missing something here, but I just don't see it. Thank you again for your attention here.

foreach var in varlist u1 u2 u3 u4 u5 u6 u7 u8 u9 u10 u11 u12 u13 u14 u15 u16 u17 u18 u19 u20 {
destring, replace ignore(".,")
}


I have also tried....

foreach v in u1-u20 {
destring, replace ignore(".,")
}

And also tried....


foreach v in varlist u1-u20 {
destring, replace ignore(".,")
}


I also tried to use a local macro:

local vars u1 u2 u3

foreach var of local vars {
destring, replace ignore(".,")
}