<?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 new rows for long periods in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-new-rows-for-long-periods/m-p/307443#M65842</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;id rx start_date   days_supply
1 a    1/1/2005     90 
2  b   2/2/2004      60 


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi all, I have the above dataset, I want to divide the periods that the patient can take drug&amp;nbsp;were days supply represent the days the patients taked the drug. For simplicity, if the patient have 90 days means patient takes the drug for 3 months. 60 for two months and so on. Here is the output I am looking for&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;id rx start_date   days_supply
1  a   1/1/2005     30
1  a   2/1/2005     30 
1  a   3/1/2005    30
2  b   2/2/2004   30
2  b   3/2/2004   30 &lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 26 Oct 2016 16:00:58 GMT</pubDate>
    <dc:creator>lillymaginta</dc:creator>
    <dc:date>2016-10-26T16:00:58Z</dc:date>
    <item>
      <title>creating new rows for long periods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-rows-for-long-periods/m-p/307443#M65842</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;id rx start_date   days_supply
1 a    1/1/2005     90 
2  b   2/2/2004      60 


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi all, I have the above dataset, I want to divide the periods that the patient can take drug&amp;nbsp;were days supply represent the days the patients taked the drug. For simplicity, if the patient have 90 days means patient takes the drug for 3 months. 60 for two months and so on. Here is the output I am looking for&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;id rx start_date   days_supply
1  a   1/1/2005     30
1  a   2/1/2005     30 
1  a   3/1/2005    30
2  b   2/2/2004   30
2  b   3/2/2004   30 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Oct 2016 16:00:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-rows-for-long-periods/m-p/307443#M65842</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2016-10-26T16:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: creating new rows for long periods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-rows-for-long-periods/m-p/307474#M65859</link>
      <description>&lt;P&gt;data have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;infile datalines;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;input id rx start_date mmddyy10. days_supply;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;format start_date mmddyy10.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;datalines;&lt;/P&gt;
&lt;P&gt;1 a 01/01/2005 90&lt;/P&gt;
&lt;P&gt;2 b 02/02/2004 60&lt;/P&gt;
&lt;P&gt;; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;months = days_supply / 30; &amp;nbsp; /* or ceil(days_supply/30) &amp;nbsp;*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;start_date_in = start_date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;do i=1 to months;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;start_date = intnx('MONth', start_date_in, i-1) + day(start_date_in) -1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;days_supply = 30;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2016 19:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-rows-for-long-periods/m-p/307474#M65859</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-10-26T19:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: creating new rows for long periods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-rows-for-long-periods/m-p/307554#M65895</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
       infile datalines;
       input id rx $ start_date mmddyy10. days_supply;
       format start_date mmddyy10.;
 datalines;
1 a 01/01/2005 90
2 b 02/02/2004 60
; run;
 
data want;
  set have;
       months = int(days_supply/30); 
	   supply=30;
       do i=1 to months;
          date = intnx('month',start_date,i-1,'s');
           output;
       end;
       KEEP ID RX supply date;
       format date mmddyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Oct 2016 03:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-rows-for-long-periods/m-p/307554#M65895</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-27T03:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: creating new rows for long periods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-rows-for-long-periods/m-p/307612#M65914</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2016 12:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-rows-for-long-periods/m-p/307612#M65914</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2016-10-27T12:18:32Z</dc:date>
    </item>
  </channel>
</rss>

