Hello,
I want to use a local macro in a loop (foreach) that will eliminate the specified characters (including blank spaces) from matching string values in a variable. I have been trying to store multiple string values that begin with a blank space (i.e. " ST" " AV" " BLVD" ...) into a local macro. After executing the macro command the display command shows nothing, and the loop will not process the data (no output). I am using Stata_IC v.13.1 and the code is:
local suffix1Y `" " ST" " AV" " BLVD" " DR" "'
disp `suffix1Y'
foreach s of local suffix1Y {
replace Bus_1Y5 = regexr(Bus_1Y5,"`s'$","")
}
I also tried storing the string values with no beginning blank spaces and adding a blank space in the regexr command (...," `s'$",...) but did not work either.
Is the problem one of syntax? I have looked at several guidelines and literature about storing string values but none seem to address this situation with beginning blank characters.
Thank you,
Enrique
I want to use a local macro in a loop (foreach) that will eliminate the specified characters (including blank spaces) from matching string values in a variable. I have been trying to store multiple string values that begin with a blank space (i.e. " ST" " AV" " BLVD" ...) into a local macro. After executing the macro command the display command shows nothing, and the loop will not process the data (no output). I am using Stata_IC v.13.1 and the code is:
local suffix1Y `" " ST" " AV" " BLVD" " DR" "'
disp `suffix1Y'
foreach s of local suffix1Y {
replace Bus_1Y5 = regexr(Bus_1Y5,"`s'$","")
}
I also tried storing the string values with no beginning blank spaces and adding a blank space in the regexr command (...," `s'$",...) but did not work either.
Is the problem one of syntax? I have looked at several guidelines and literature about storing string values but none seem to address this situation with beginning blank characters.
Thank you,
Enrique
Comment