Replacing string value using if option in Stata
<p>I cannot figure out how to tell Stata to replace the value of a string variable only if the value of another (also) string variable is equal to "xxx"? To illustrate the problem: I need to merge two datasets according to the match in the name of the municipality (unfortunately, I do not have anything else that is common for the both datasets). In the first dataset, there are several hospitals with the municipality name "Frankfurt". In the second dataset, there are two occurrences of Frankfurt: "Frankfurt am Main" and "Frankfurt (Oden)". Both of them have a hospital. Consequently, I have to employ additional criteria to distinguish between them. In other words, I cannot tell Stata simply to replace all municipality values "Frankfurt" by e.g. "Frankfurt am Main" (in this case I could use command </p>

<pre><code>replace ort = subinstr(ort, "Frankfurt", "Frankfurt am Main", .)   
</code></pre>

<p>but I have to firstly find where the hospital is situated with the help of its designation and afterwards to tell Stata to e.g. replace Frankfurt by FaM if designation=="xxx". I suppose it shouldn't be that difficult command but I cannot find it. </p>