<?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 dividing time periods into intervals in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/dividing-time-periods-into-intervals/m-p/544620#M150627</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input id$2. start  end ;
attrib start format =date9. informat=date9.;
attrib end format =date9. informat=date9.;
datalines;
1 01OCT2014 14JUN2015
1 01OCT2015 14NOV2015
2 18FEB2015 30APR2015;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the above data. The max time between the start and the end date is 270 days.&lt;/P&gt;&lt;P&gt;I want to divide the periods into intervals:&lt;/P&gt;&lt;P&gt;period1: 0-90&lt;/P&gt;&lt;P&gt;Period2: 91-180&lt;/P&gt;&lt;P&gt;Period3: 181-270, all would be calculated from the start date.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output&lt;/P&gt;&lt;P&gt;id start&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; period&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token data string"&gt;1 01OCT2014 30DEC2014&amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token data string"&gt;1&amp;nbsp;30DEC2014 30MAR2015&amp;nbsp; &amp;nbsp;2&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token data string"&gt;1&amp;nbsp;30MAR2015&amp;nbsp;14JUN2015&amp;nbsp; &amp;nbsp;3&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token data string"&gt;1 01OCT2015 14NOV2015&amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token data string"&gt;2 18FEB2015 30APR2015&amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE class="  language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Mar 2019 15:56:04 GMT</pubDate>
    <dc:creator>lillymaginta</dc:creator>
    <dc:date>2019-03-20T15:56:04Z</dc:date>
    <item>
      <title>dividing time periods into intervals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dividing-time-periods-into-intervals/m-p/544620#M150627</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input id$2. start  end ;
attrib start format =date9. informat=date9.;
attrib end format =date9. informat=date9.;
datalines;
1 01OCT2014 14JUN2015
1 01OCT2015 14NOV2015
2 18FEB2015 30APR2015;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the above data. The max time between the start and the end date is 270 days.&lt;/P&gt;&lt;P&gt;I want to divide the periods into intervals:&lt;/P&gt;&lt;P&gt;period1: 0-90&lt;/P&gt;&lt;P&gt;Period2: 91-180&lt;/P&gt;&lt;P&gt;Period3: 181-270, all would be calculated from the start date.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output&lt;/P&gt;&lt;P&gt;id start&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; period&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token data string"&gt;1 01OCT2014 30DEC2014&amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token data string"&gt;1&amp;nbsp;30DEC2014 30MAR2015&amp;nbsp; &amp;nbsp;2&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token data string"&gt;1&amp;nbsp;30MAR2015&amp;nbsp;14JUN2015&amp;nbsp; &amp;nbsp;3&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token data string"&gt;1 01OCT2015 14NOV2015&amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token data string"&gt;2 18FEB2015 30APR2015&amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE class="  language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 15:56:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dividing-time-periods-into-intervals/m-p/544620#M150627</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2019-03-20T15:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: dividing time periods into intervals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dividing-time-periods-into-intervals/m-p/544627#M150632</link>
      <description>&lt;P&gt;This seems to work for the example data:&lt;/P&gt;
&lt;PRE&gt;data test;
input id$2. start  end ;
attrib start format =date9. informat=date9.;
attrib end format =date9. informat=date9.;
datalines;
1 01OCT2014 14JUN2015
1 01OCT2015 14NOV2015
2 18FEB2015 30APR2015
;
run;

data want;
   set test;
   period=0;
   tend = end;
   do start = start to end by 90;
      period= period+1;
      end= intnx('day',start,90);
      if end&amp;gt;tend then end=tend;
      output;
   end;
   drop tend;
run;
      &lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Mar 2019 16:08:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dividing-time-periods-into-intervals/m-p/544627#M150632</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-20T16:08:42Z</dc:date>
    </item>
  </channel>
</rss>

