title: Trailing zeros in string format in Stata
body: <p>I am trying to convert a <strong>string</strong> variable <code>A</code> in Stata to a <strong>string</strong> variable <code>B</code> such that each observation has a fixed length. For example the string variable A is</p>
  
  <pre><code>85
  01
  3
  </code></pre>
  
  <p>and I want to convert it to another string variable <code>B</code> with <strong>trailing zeros</strong> in order to get length 5 for each observations</p>
  
  <pre><code>85000
  01000
  30000
  </code></pre>
  
  <p>I know that in order to put <strong>leading zeros</strong> this code works
  <code>gen B= string(real(A),"%05.0f")</code>. How should it be modified in order to get trailing zeros?</p>