title: Stata type mismatch, and no report of line number where error happened
body: <p>I googled about "type mismatch", and it seems the errors mostly come from "replace"</p>
  
  <p>Indeed I am doing some replacing but I can't see where that error comes from.</p>
  
  <pre><code>generate price=0.0
  replace price=105.17 if year==2014
  
  gen crisis=1 if year==2008 | year==2009
  replace crisis=0 if year&lt;2008 | year&gt;2009
  
  gen postcrisis=1 if year&gt;2008
  replace postcrisis=0 if year&lt;=2008
  </code></pre>
  
  <p>Also, Stata isn't displaying at which line the error happened. This is very bad for debugging. How can I make it?</p>
  
  <p>======================================</p>
  
  <p>The error was coming from </p>
  
  <pre><code>generate realsales=sales/price
  </code></pre>
  
  <p>To see what is going wrong, I did the following.</p>
  
  <pre><code>. describe sales price
  
                storage   display    value
  variable name   type    format     label      variable
  &gt;  label
  ------------------------------------------------------
  sales           str8    %9s                   
  price           float   %9.0g         
  </code></pre>
  
  <p>And destring didn't work.</p>
  
  <pre><code>. destring sales, replace
  sales contains nonnumeric characters; no replace
  </code></pre>
  
  <p>Also, dataex didn't work.</p>
  
  <pre><code>. dataex
  input statement exceeds linesize limit. Try specifying fewer variables
  </code></pre>
  
  <p>And still, when Stata stops with an error, it never tells me which line is causing the error. It simply shows me the following lines.</p>
  
  <pre><code>112. 
  . }
  
  (146 vars, 10748 obs)
  type mismatch
  r(109);
  
  end of do-file
  
  r(109);
  </code></pre>
  
  <p>This is very inconvenient for debugging. Is it really like this? Is there any way to make Stata display the error line?</p>