<?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: Difference between dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates/m-p/247263#M268625</link>
    <description>&lt;P&gt;Use the lag function to obtain the previous value of the end date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by customerID;

contract_end = lag1(end_date);

if first.customerID then do;
   renewal=.;
end;
else renewal = datepart(start_date)-datepart(contract_end);

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 01 Feb 2016 18:07:06 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-02-01T18:07:06Z</dc:date>
    <item>
      <title>Difference between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates/m-p/247261#M268623</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are the insurance policies with customer_id, policy_id, revision_id and policy start and end dates.&lt;/P&gt;&lt;P&gt;I want to calculate the day between the renewal of two policies for the same customer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some policies may have revisions (added some extra coverage) with same policy_id and end_date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the sample data&amp;amp;colon;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1699i5F3361CCAE695E36/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.JPG" title="Capture.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example for the policies 1247 and 1389, renewal day is: 365&lt;/P&gt;&lt;P&gt;For 1389 and 1543 it is: 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;&lt;P&gt;Onur&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2016 17:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates/m-p/247261#M268623</guid>
      <dc:creator>dincoo</dc:creator>
      <dc:date>2016-02-01T17:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates/m-p/247263#M268625</link>
      <description>&lt;P&gt;Use the lag function to obtain the previous value of the end date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by customerID;

contract_end = lag1(end_date);

if first.customerID then do;
   renewal=.;
end;
else renewal = datepart(start_date)-datepart(contract_end);

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Feb 2016 18:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates/m-p/247263#M268625</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-01T18:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates/m-p/247382#M268626</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;The problem is many policies have revisions -as ı stated at example- with the same policy_id and end_date and different start_date (revision_date).&lt;/P&gt;&lt;P&gt;I want the date difference only between different policy_ids.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 08:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates/m-p/247382#M268626</guid>
      <dc:creator>dincoo</dc:creator>
      <dc:date>2016-02-02T08:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates/m-p/247420#M268627</link>
      <description>What do you want the output to look like? Do you keep the revisions in the file? If so, what should duration be.</description>
      <pubDate>Tue, 02 Feb 2016 12:00:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates/m-p/247420#M268627</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-02T12:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates/m-p/247429#M268628</link>
      <description>I just want to choose the customers who's min 2 different policy_ids and the date between ex policy end date and new policy date are greater than 1 month</description>
      <pubDate>Tue, 02 Feb 2016 12:18:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-dates/m-p/247429#M268628</guid>
      <dc:creator>dincoo</dc:creator>
      <dc:date>2016-02-02T12:18:00Z</dc:date>
    </item>
  </channel>
</rss>

