<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to count consecutive days? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-count-consecutive-days/m-p/434331#M68879</link>
    <description>&lt;P&gt;Assuming your dates are actual SAS dates and not character strings:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
&amp;nbsp; &amp;nbsp; set have;&lt;BR /&gt;    year=year(station_date);
&amp;nbsp; &amp;nbsp; if month(station_date)=1 and day(station_date)=1 then consec=0;
    if mean&amp;lt;8 then consec+1;
    else if mean&amp;gt;=8 then consec=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can use PROC SUMMARY to obtain the max values of variable CONSEC in each year;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 05 Feb 2018 18:42:59 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-02-05T18:42:59Z</dc:date>
    <item>
      <title>How to count consecutive days?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-count-consecutive-days/m-p/434324#M68878</link>
      <description>&lt;P&gt;Hi,&amp;nbsp; I am pretty new to SAS programming and teaching myself out of necessity. I am trying to figure out the consecutive days that mean daily water temperature remained below a threshold temperature (8 degrees Celsius).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example of what my data looks like:&lt;/P&gt;&lt;P&gt;Minimum&amp;nbsp; Maximum&amp;nbsp; &amp;nbsp;Mean&amp;nbsp; Count&amp;nbsp; &amp;nbsp;Station Date&lt;/P&gt;&lt;P&gt;4.1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10.6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7.9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20160102&lt;/P&gt;&lt;P&gt;4.2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9.1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7.6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20160103&lt;/P&gt;&lt;P&gt;4.0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8.9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7.3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20160104&lt;/P&gt;&lt;P&gt;4.0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9.0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7.4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20160105&lt;/P&gt;&lt;P&gt;3.9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8.9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7.0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20160106&lt;/P&gt;&lt;P&gt;4.1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9.2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7.9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20160107&lt;/P&gt;&lt;P&gt;4.4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10.4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7.8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20160108&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For station date, the date is set up as yyyymmdd.&amp;nbsp; This can be changed if need be, this is just how we input dates in our database.&amp;nbsp; Minimum, maximum, and mean all refer to water temperature&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've already separated all of the mean water temperature data below 8 o C, and all I want are the maximum consecutive days for each year&amp;nbsp; (meaning the maximum number of CONSECUTIVE days that the temperature was below 8 o C.&amp;nbsp; My year data range from 1991-2017.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried out some code, but nothing has been very successful yet.&amp;nbsp; I tried modifying this tutorial :&lt;A href="http://support.sas.com/kb/33/838.html" target="_blank"&gt;http://support.sas.com/kb/33/838.html&lt;/A&gt;, but I'm having trouble discerning where parts of the data example come from.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the data I want:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Year&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Maximum Consecutive Days&lt;/P&gt;&lt;P&gt;1991&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20&lt;/P&gt;&lt;P&gt;1992&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 34&lt;/P&gt;&lt;P&gt;1993&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 42&lt;/P&gt;&lt;P&gt;1994&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 26&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(for example).&amp;nbsp; What kind of procedure can I use to achieve this?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 18:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-count-consecutive-days/m-p/434324#M68878</guid>
      <dc:creator>jswinford</dc:creator>
      <dc:date>2018-02-05T18:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to count consecutive days?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-count-consecutive-days/m-p/434331#M68879</link>
      <description>&lt;P&gt;Assuming your dates are actual SAS dates and not character strings:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
&amp;nbsp; &amp;nbsp; set have;&lt;BR /&gt;    year=year(station_date);
&amp;nbsp; &amp;nbsp; if month(station_date)=1 and day(station_date)=1 then consec=0;
    if mean&amp;lt;8 then consec+1;
    else if mean&amp;gt;=8 then consec=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can use PROC SUMMARY to obtain the max values of variable CONSEC in each year;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 18:42:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-count-consecutive-days/m-p/434331#M68879</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-02-05T18:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to count consecutive days?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-count-consecutive-days/m-p/434350#M68881</link>
      <description>&lt;P&gt;Are you doing a degree day type calculation?&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 19:24:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-count-consecutive-days/m-p/434350#M68881</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-05T19:24:41Z</dc:date>
    </item>
  </channel>
</rss>

