<?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 create a report by assigning Start and End Date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/478105#M286015</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Business Logic:- Treatment period for a drug would be the period from the first date of use to the last date of use. The latter is the date when there is at least a 60/30/90 day gap between the end date of usage of one claim and the claim date of the next claim of the same drug&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But we don't know what this means: "at least a 60/30/90 day gap between the end date of usage of one claim and the claim date of the next claim of the same drug". What is a 60/30/90 day gap? We know what a 60 day gap mans. We know what a 30 day gap means. We know what a 90 day gap means. We don't know what a 60/30/90 day gap is.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Does the variable DAYSSUP have any role to play here? If so, explain.&lt;/P&gt;</description>
    <pubDate>Sat, 14 Jul 2018 11:03:15 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-07-14T11:03:15Z</dc:date>
    <item>
      <title>How to create a report by assigning Start and End Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/475672#M286010</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I am facing the problem in assigning start and end date in each drug usage in the following data set, I don't know how should I do this, please help me on this,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Mediciene;
   input PTID $ 1-8 Dayssup 10-11 @13 Drug_dt date11. Drug $23-36;
   format Drug_dt date9.;
   datalines;
21847081 28	16-Oct-08 dexamethasone
21847081 28	04-Dec-08 dexamethasone
21847081 30	30-Dec-08 dexamethasone
21847081 28	01-Feb-09 dexamethasone
21847081 30	10-Aug-10 dexamethasone
21847081 30	24-Sep-10 dexamethasone
21847081 30	06-Nov-10 dexamethasone
21847081 28	07-Jun-12 dexamethasone
21847081 28	06-Jul-12 dexamethasone
21847081 28	14-Aug-12 dexamethasone
21847081 28	14-Sep-12 dexamethasone
21847081 28	28-Oct-12 dexamethasone
21847081 28	06-Dec-02 dexamethasone
21847081 28	18-Jan-13 dexamethasone
21847081 21	24-Sep-10 Lenalidomide
21847081 21	20-Oct-10 Lenalidomide
21847081 21	18-Nov-10 Lenalidomide
21847081 21	16-Dec-10 Lenalidomide
21847081 21	18-Jan-11 Lenalidomide
21847081 21	10-Feb-11 Lenalidomide
21847081 21	14-Mar-11 Lenalidomide
21847081 21	01-Jun-12 Lenalidomide
21847081 21	26-Jun-12 Lenalidomide
21847081 21	19-Jul-12 Lenalidomide
21847081 21	23-Aug-12 Lenalidomide
21847081 21	18-Sep-12 Lenalidomide
21847081 21	19-Oct-12 Lenalidomide
21847081 21	14-Nov-12 Lenalidomide
21847081 21	13-Dec-12 Lenalidomide
21847081 21	14-Jan-13 Lenalidomide
21847081 90	12-Mar-13 prednisolone
21847081 89	25-Jun-13 prednisolone
21847081 28	15-Oct-08 thalidomide
21847081 28	04-Dec-08 thalidomide
21847081 28	05-Jan-09 thalidomide
21847081 28	28-Jan-09 thalidomide
21847081 28	02-Mar-09 thalidomide
21847081 28	27-Mar-09 thalidomide
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Business Logic:- Treatment period for a drug would be the period from the first date of use to the last date of use. The latter is the date when there is at least a 60/30/90 day gap(Here the gap is 90 days for &lt;SPAN&gt;dexamethasone and 60 days for all other drugs&lt;/SPAN&gt;) between the end date of usage of one claim (Start date + days supply) and the claim date of the next claim of the same drug.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PTID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Drug_dt&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Drug&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Startdate + days&amp;nbsp;supply&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Gap&lt;/STRONG&gt;&lt;BR /&gt;21847081&amp;nbsp; &amp;nbsp;28 16-Oct-08&amp;nbsp; &amp;nbsp; &amp;nbsp;dexamethasone&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12-nov-08&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;22&lt;BR /&gt;21847081&amp;nbsp; &amp;nbsp;28 04-Dec-08&amp;nbsp; &amp;nbsp; dexamethasone&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;31-dec-08&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-1&lt;BR /&gt;21847081&amp;nbsp; &amp;nbsp;30 30-Dec-08&amp;nbsp; &amp;nbsp; dexamethasone&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;28-jan-09&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;BR /&gt;21847081&amp;nbsp; &amp;nbsp;28 01-Feb-09&amp;nbsp; &amp;nbsp; dexamethasone&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;28-feb-09&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;528&lt;BR /&gt;21847081&amp;nbsp; &amp;nbsp;30 10-Aug-10&amp;nbsp; &amp;nbsp; dexamethasone&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;08-sep-10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 16&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For&amp;nbsp;&lt;SPAN&gt;dexamethasone in above table, the gap days is less than 90 till row 4. so it will become a single regimn containing&amp;nbsp;dexamethasone with start date of&amp;nbsp;16-Oct-08 and end date of&amp;nbsp;28-Feb-09. And there will be a different start date of&amp;nbsp;10-Aug-10 as there is gap of more than 90 days. Applying the same logic in all data, we get final table (desired Output).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create desired output like this(Below), but I am unabling to do so,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output data Set (Desired Output):-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PTID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Dayssup&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Drug&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Stdt&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;enddt&lt;/STRONG&gt;&lt;BR /&gt;21847081&amp;nbsp; &amp;nbsp;30&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dexamethasone&amp;nbsp; &amp;nbsp;16Oct2008&amp;nbsp; &amp;nbsp; 28Feb2009&lt;BR /&gt;21847081&amp;nbsp; &amp;nbsp;28&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dexamethasone&amp;nbsp; &amp;nbsp;10Aug2010&amp;nbsp; &amp;nbsp;05Dec2010&lt;BR /&gt;21847081&amp;nbsp; &amp;nbsp;28&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dexamethasone&amp;nbsp; &amp;nbsp;07jun2012&amp;nbsp; &amp;nbsp; 14feb2013&lt;BR /&gt;21847081&amp;nbsp; &amp;nbsp;21&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Lenalidomide&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;24sep2010&amp;nbsp; &amp;nbsp; 03apr2011&lt;BR /&gt;21847081&amp;nbsp; &amp;nbsp;21&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Lenalidomide&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01jun2012&amp;nbsp; &amp;nbsp; 03feb2013&lt;BR /&gt;21847081&amp;nbsp; &amp;nbsp;89&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; prednisolone&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12mar2013&amp;nbsp; &amp;nbsp; 21sep2013&lt;BR /&gt;21847081&amp;nbsp; &amp;nbsp;28&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; thalidomide&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15Oct2008&amp;nbsp; &amp;nbsp; &amp;nbsp;23apr2009&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 14:56:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/475672#M286010</guid>
      <dc:creator>umeshgiri48</dc:creator>
      <dc:date>2018-07-16T14:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a report by assigning Start and End Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/475684#M286011</link>
      <description>&lt;P&gt;Post test data in the form of a datastep.&lt;/P&gt;
&lt;P&gt;Post required output in the body of the text of the post.&lt;/P&gt;
&lt;P&gt;Explain the logic between the two.&lt;/P&gt;
&lt;P&gt;Show what code you have written and where you are stuck.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 15:24:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/475684#M286011</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-07-05T15:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a report by assigning Start and End Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/476487#M286012</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have edited the code as you have asked, I don't know what code should I write so that I can get a desired output, can you help me on this?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 15:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/476487#M286012</guid>
      <dc:creator>umeshgiri48</dc:creator>
      <dc:date>2018-07-09T15:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a report by assigning Start and End Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/476530#M286013</link>
      <description>&lt;P&gt;And now you have to describe the logic linking both datasets.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 17:07:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/476530#M286013</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2018-07-09T17:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a report by assigning Start and End Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/478101#M286014</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Now I have defined the logic between the both the data sets, have a look and help me on this.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Jul 2018 09:03:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/478101#M286014</guid>
      <dc:creator>umeshgiri48</dc:creator>
      <dc:date>2018-07-14T09:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a report by assigning Start and End Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/478105#M286015</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Business Logic:- Treatment period for a drug would be the period from the first date of use to the last date of use. The latter is the date when there is at least a 60/30/90 day gap between the end date of usage of one claim and the claim date of the next claim of the same drug&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But we don't know what this means: "at least a 60/30/90 day gap between the end date of usage of one claim and the claim date of the next claim of the same drug". What is a 60/30/90 day gap? We know what a 60 day gap mans. We know what a 30 day gap means. We know what a 90 day gap means. We don't know what a 60/30/90 day gap is.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Does the variable DAYSSUP have any role to play here? If so, explain.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Jul 2018 11:03:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/478105#M286015</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-14T11:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a report by assigning Start and End Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/478384#M286016</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have uploaded the whole case study with all the details, can you please help me on this!&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 14:59:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/478384#M286016</guid>
      <dc:creator>umeshgiri48</dc:creator>
      <dc:date>2018-07-16T14:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a report by assigning Start and End Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/478398#M286017</link>
      <description>&lt;P&gt;I think this will do it. Note: I have fixed a typo in your original data. Assumes data is sorted by patient and drug and drug_dt.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Mediciene;
   input PTID $ 1-8 Dayssup 10-11 @13 Drug_dt date11. Drug $23-36;
   end_of_supply=intnx('days',drug_dt,dayssup)-1;
   prev_drug=lag(drug);
   prev_end_of_supply=lag(end_of_supply);
   gap=drug_dt-prev_end_of_supply;
   if drug^=prev_drug then group=0;
   if drug=prev_drug and ((drug='dexamethasone' and gap&amp;gt;90) or
        (drug^='dexamethasone' and gap&amp;gt;60)) then group+1;
   format Drug_dt end_of_supply date9.;
   datalines;
21847081 28	16-Oct-08 dexamethasone
21847081 28	04-Dec-08 dexamethasone
21847081 30	30-Dec-08 dexamethasone
21847081 28	01-Feb-09 dexamethasone
21847081 30	10-Aug-10 dexamethasone
21847081 30	24-Sep-10 dexamethasone
21847081 30	06-Nov-10 dexamethasone
21847081 28	07-Jun-12 dexamethasone
21847081 28	06-Jul-12 dexamethasone
21847081 28	14-Aug-12 dexamethasone
21847081 28	14-Sep-12 dexamethasone
21847081 28	28-Oct-12 dexamethasone
21847081 28	06-Dec-12 dexamethasone
21847081 28	18-Jan-13 dexamethasone
21847081 21	24-Sep-10 Lenalidomide
21847081 21	20-Oct-10 Lenalidomide
21847081 21	18-Nov-10 Lenalidomide
21847081 21	16-Dec-10 Lenalidomide
21847081 21	18-Jan-11 Lenalidomide
21847081 21	10-Feb-11 Lenalidomide
21847081 21	14-Mar-11 Lenalidomide
21847081 21	01-Jun-12 Lenalidomide
21847081 21	26-Jun-12 Lenalidomide
21847081 21	19-Jul-12 Lenalidomide
21847081 21	23-Aug-12 Lenalidomide
21847081 21	18-Sep-12 Lenalidomide
21847081 21	19-Oct-12 Lenalidomide
21847081 21	14-Nov-12 Lenalidomide
21847081 21	13-Dec-12 Lenalidomide
21847081 21	14-Jan-13 Lenalidomide
21847081 90	12-Mar-13 prednisolone
21847081 89	25-Jun-13 prednisolone
21847081 28	15-Oct-08 thalidomide
21847081 28	04-Dec-08 thalidomide
21847081 28	05-Jan-09 thalidomide
21847081 28	28-Jan-09 thalidomide
21847081 28	02-Mar-09 thalidomide
21847081 28	27-Mar-09 thalidomide
;

proc summary nway data=mediciene;
	class ptid drug group;
	var drug_dt end_of_supply;
	output out=want min(drug_dt)=stdt max(end_of_supply)=enddt;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/478398#M286017</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-16T17:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a report by assigning Start and End Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/478406#M286018</link>
      <description>&lt;P&gt;There seems to be a mistake in the data provided, the year in in line&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;21847081 28 06-Dec-02 dexamethasone&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;should be (20)12, not (20)02, right?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to get a solution yourself, you will want to look for documentation explaining&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;look-ahead technique.&lt;/LI&gt;
&lt;LI&gt;by-groups&lt;/LI&gt;
&lt;LI&gt;first/last&lt;/LI&gt;
&lt;LI&gt;date calculations&lt;/LI&gt;
&lt;LI&gt;retain-statement&lt;/LI&gt;
&lt;LI&gt;output-statement&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;The following solution needs further testing before i would call it stable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.want;
   if eof = 0 then do;
      set work.Mediciene(firstobs= 2 keep= Drug_dt rename=(Drug_dt=NextStart)) end=eof;
   end;

   set work.Mediciene;
   by ptid Drug notsorted;

   length StartDate EndDate 8 outmarker 8;
   format StartDate EndDate date9.;
   retain StartDate;

   EndDate = drug_dt + dayssup -1;

   if first.Drug then do;
      NextStart = EndDate;
      StartDate = drug_dt;
   end; 

   Gap = NextStart - EndDate;
   outmarker = 0;

   if lowcase(Drug) = 'dexamethasone' then do;
      if Gap &amp;gt; 90 then do;
         outmarker = 1;
      end;
   end;
   else do;
      if Gap &amp;gt; 60 then do;
         outmarker = 2;
      end;
   end;

   if last.drug then do;
      outmarker = 3;
   end;


   if outmarker &amp;gt; 0 then do;
      output;
      StartDate = NextStart;
   end;

   drop outmarker Drug_dt Gap;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 15:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-report-by-assigning-Start-and-End-Date/m-p/478406#M286018</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-07-16T15:55:20Z</dc:date>
    </item>
  </channel>
</rss>

