if statement – Replacing string value using if option in Stata
You seem to have answered your own question, so I am not clear where the puzzlement lies. Otherwise put, you dont show syntax you tried that did not do what you wanted.
replace ort = subinstr(ort, Frankfurt, Frankfurt am Main, .) if designation == XXX
will be legal if
designation is a variable name and the string
XXX is exactly what you want to check for.
if as used here is a qualifier, not an option.