title: Replace zeros with missing values in certain cases
body: <p>I was wondering if anyone knew an easier way of doing the following:</p>
  
  <p>I have a dataset of health facility caseload by year, where each observation is one health facility. Facilities were 'brought online' in different years, so some have zeros before they have values for caseload. Also, some 'discontinue', as in they did provide services, but don't any more. I would like to replace the zeros with missing values for the years in which a facility discontinued. In the following example, the 3rd and 4th facilities discontinued, so I'd like missing for <code>y2014</code> for the 3rd and <code>y2013</code> &amp; <code>y2014</code> for the 4th.</p>
  
  <p><code>y2011  y2012   y2013   y2014
      0     0       76     82
      0     0       29     13
      0     0       25     0<br>
      5     10       0     0
      0     0       17     24</code></p>
  
  <p>I tried the following, which worked, but I'm going to have many years worth of data to work on (2000-2014), so was wondering if there was a more efficient way.</p>
  
  <p><code>replace y2014=. if y2014==0 &amp; (y2013&gt;0 | y2012&gt;0 | y2011&gt;0)
  replace y2013=. if y2013==0 &amp; ( y2012&gt;0 | y2011&gt;0)
  replace y2012=. if y2012==0 &amp; ( y2011&gt;0)</code></p>
  
  <p>I messed around with <code>egen rowlast</code> to identify the facilities with a zero in the last year (meaning they discontinued), but then wasn't sure where to go with it.</p>