title: How to remove contents of string after a character
body: <p>I'm cleaning a variable - <code>last_name</code> - that for some names the middle name is included after a comma, while for most names the middle name is stored in the variable <code>middle_name</code>. </p>
  
  <p>Here are some examples:</p>
  
  <pre><code>last_name
  Smith, R
  Anderson, Jay
  Epps,William
  McKinsey,F
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>split last_name, p(,)
  replace last_name = substr(last_name, 1, length(last_name)-3) if ///
              length(last_name2)==3 
  </code></pre>
  
  <p>I could put this through a forvalues loop and increase the length of the strings I'm dropping but this feels like a crude method. Is there a cleaner way to drop all of the values after the comma (or any other character)?</p>