I have a string field city with several internal ", " sub-strings (comma followed by a space), some of which appear at the end of the string. For example:
Tulsa, OK
Wichita, KS
Sioux Falls, SD, (note the trailing space)
For any row with a trailing comma-space, I want to erase that segment of the string (the comma and space). I expected to achieve the desired functionality with the command below, but it does not seem to be executing as hoped. In fact, it seems to delete the entire string value for those rows meeting the if condition.
replace city=subinstr(substr(city, -2, 2), ", ", "", .) if substr(hs_address, -2, 2)==", "
Any thoughts on how this is being mis-specified?
Tulsa, OK
Wichita, KS
Sioux Falls, SD, (note the trailing space)
For any row with a trailing comma-space, I want to erase that segment of the string (the comma and space). I expected to achieve the desired functionality with the command below, but it does not seem to be executing as hoped. In fact, it seems to delete the entire string value for those rows meeting the if condition.
replace city=subinstr(substr(city, -2, 2), ", ", "", .) if substr(hs_address, -2, 2)==", "
Any thoughts on how this is being mis-specified?
Comment