Hi all,
I'm stuck on what I think is a very simple issue of replacing certain parts of a string with some other character. I have a bunch of punctuation like ",","/" etc and I'm trying to remove them or replace them. Please consider the following code:
Rest of the loop works fine, but when it comes to
the result becomes weird because of
where "=" part of "=>" is worked by the latter code.
Similar problem for
and
where "/" part of "K/" is worked by former code.
Any way to resolve this issue?
Thanks,
I'm stuck on what I think is a very simple issue of replacing certain parts of a string with some other character. I have a bunch of punctuation like ",","/" etc and I'm trying to remove them or replace them. Please consider the following code:
Code:
foreach var of varlist A B C D E{ replace `var' = subinstr(`var', ".", "",.) replace `var' = subinstr(`var', "-", "",.) replace `var' = subinstr(`var', ";", "",.) replace `var' = subinstr(`var', "(", "",.) replace `var' = subinstr(`var', ")", "",.) replace `var' = subinstr(`var', ",", "",.) replace `var' = subinstr(`var', ".", "",.) replace `var' = subinstr(`var', "/", " OR ",.) replace `var' = subinstr(`var', ">", "GREATER THAN ",.) replace `var' = subinstr(`var', "=>", "GREATER THAN OR EQUAL TO ",.) replace `var' = subinstr(`var', "K/", "KGs PER",.) }
Code:
replace `var' = subinstr(`var', "=>", "GREATER THAN OR EQUAL TO ",.)
Code:
replace `var' = subinstr(`var', ">", "GREATER THAN ",.)
Similar problem for
Code:
replace `var' = subinstr(`var', "/", " OR ",.)
Code:
replace `var' = subinstr(`var', "K/", "KGs PER",.)
Any way to resolve this issue?
Thanks,
Comment