<?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 creating time intervals 30 days in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-time-intervals-30-days/m-p/535848#M147185</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
  input patientid  start : mmddyy10.  end : mmddyy10. ;
  format   start end  mmddyy10.;
datalines;
1  1/1/2006 4/1/2006
 
2   1/2/2006 12/2/2007;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have data that contains one row per patient with start and end date. I want to create 30 days interval following the start date until the end date. The output would be :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 1/1/2006 31/12006&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 31/1/2006&amp;nbsp; 3/2/2006&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 3/2/2006&amp;nbsp; &amp;nbsp;4/1/2006&lt;/P&gt;&lt;P&gt;2 1/2/2006&amp;nbsp; 2/1/2006&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and so on&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Feb 2019 13:19:29 GMT</pubDate>
    <dc:creator>lillymaginta</dc:creator>
    <dc:date>2019-02-15T13:19:29Z</dc:date>
    <item>
      <title>creating time intervals 30 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-time-intervals-30-days/m-p/535848#M147185</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
  input patientid  start : mmddyy10.  end : mmddyy10. ;
  format   start end  mmddyy10.;
datalines;
1  1/1/2006 4/1/2006
 
2   1/2/2006 12/2/2007;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have data that contains one row per patient with start and end date. I want to create 30 days interval following the start date until the end date. The output would be :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 1/1/2006 31/12006&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 31/1/2006&amp;nbsp; 3/2/2006&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 3/2/2006&amp;nbsp; &amp;nbsp;4/1/2006&lt;/P&gt;&lt;P&gt;2 1/2/2006&amp;nbsp; 2/1/2006&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and so on&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 13:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-time-intervals-30-days/m-p/535848#M147185</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2019-02-15T13:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: creating time intervals 30 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-time-intervals-30-days/m-p/535851#M147187</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
  input patientid  start : mmddyy10.  end : mmddyy10. ;
  format   start end  date9.;
datalines;
1  1/1/2006 4/1/2006
2   1/2/2006 12/2/2007
;
run;


data want;
set a(rename=end=_end);
do while(start&amp;lt;_end);
end=intnx('days',start,30);
output;
start=end;
end;
format start end mmddyy10.;
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Feb 2019 14:00:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-time-intervals-30-days/m-p/535851#M147187</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-15T14:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: creating time intervals 30 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-time-intervals-30-days/m-p/535852#M147188</link>
      <description>&lt;P&gt;Here's one way to approach the problem.&amp;nbsp; It's untested code, so you will have to verify whether the results are correct:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;original_end = end;&lt;/P&gt;
&lt;P&gt;do while (end - start &amp;gt; 30);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end = start + 30;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;start = end ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end = original_end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;drop original_end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notice how it's a little harder to read because END is both a SAS statement and a variable name.&amp;nbsp; If it's within your control, try to avoid that situation.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 14:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-time-intervals-30-days/m-p/535852#M147188</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-15T14:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: creating time intervals 30 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-time-intervals-30-days/m-p/535853#M147189</link>
      <description>&lt;P&gt;Please be consistent with your date formatting. I suggest to use the yymmddd10. format, as that is ISO-compliant.&lt;/P&gt;
&lt;P&gt;As it is, some of your dates in then output seem to be DMY order, while others are MDY.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 14:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-time-intervals-30-days/m-p/535853#M147189</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-02-15T14:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: creating time intervals 30 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-time-intervals-30-days/m-p/535855#M147190</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 14:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-time-intervals-30-days/m-p/535855#M147190</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2019-02-15T14:12:28Z</dc:date>
    </item>
  </channel>
</rss>

