title: SAS - Create a count which increases in every observation, but resets to zero based on the value of a binary variable
body: <p>I have a dataset which includes the following two variables (it includes more, but for simplicity's sake, I'll just discuss these two): Date and Hot</p>
  
  <p>Date is a SAS date variable and Hot is a binary (0,1) variable.</p>
  
  <p>I'd like to read the dataset and have a count variable which counts the number of days in a row where the Hot variable is a 1.</p>
  
  <p>This is an example of what my data look like:</p>
  
  <pre><code>Date          Hot
  
  14JUN2010     0
  15JUN2010     1
  16JUN2010     1
  17JUN2010     0
  18JUN2010     1
  19JUN2010     1
  20JUN2010     1
  21JUN2010     0
  </code></pre>
  
  <p>This is an example of what I would like my data to look like:</p>
  
  <pre><code>Date          Hot    HotDays
  
  14JUN2010     0      0
  15JUN2010     1      1
  16JUN2010     1      2
  17JUN2010     0      0
  18JUN2010     1      1
  19JUN2010     1      2
  20JUN2010     1      3
  21JUN2010     0      0
  </code></pre>
  
  <p>I've tried a number of different things, none of which work. I've read up on the retain statement and group by processing, but I haven't figured out how to adapt those strategies to counting sequential dates by binary variable.</p>
  
  <p>Thanks for your help. </p>