<?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: Find maximum difference between date column and current date in years. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-maximum-difference-between-date-column-and-current-date-in/m-p/692746#M211101</link>
    <description>I have updated the example</description>
    <pubDate>Tue, 20 Oct 2020 05:36:08 GMT</pubDate>
    <dc:creator>Saurabh_Rana</dc:creator>
    <dc:date>2020-10-20T05:36:08Z</dc:date>
    <item>
      <title>Find maximum difference between date column and current date in years.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-maximum-difference-between-date-column-and-current-date-in/m-p/692742#M211098</link>
      <description>&lt;P&gt;I have customer policy data where customer can have multiple policies against his/her name along with the policy start date. I want to derive the time in years since the customer is associated with us so basically I want to find time between the policy start date of the first policy and the current date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example-&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Input&lt;BR /&gt;&lt;BR /&gt;Customer_Name Policy_Start_Date
cust_1        20/10/2019&lt;BR /&gt;cust_1        20/02/2020 
cust_2        20/10/2018
cust_2        26/10/2019 
&lt;BR /&gt;Output&amp;nbsp;

Customer_Name Customer_Since
cust_1        1 Year
cust_2        2 Year&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 05:36:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-maximum-difference-between-date-column-and-current-date-in/m-p/692742#M211098</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2020-10-20T05:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: Find maximum difference between date column and current date in years.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-maximum-difference-between-date-column-and-current-date-in/m-p/692744#M211099</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; customer can have multiple policies against his/her name along with the policy start date&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Isn't that the same as finding the minimum (oldest) date for each customer?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look at the different options of the INTCK function to derive the number of years the way you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 05:30:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-maximum-difference-between-date-column-and-current-date-in/m-p/692744#M211099</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-10-20T05:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Find maximum difference between date column and current date in years.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-maximum-difference-between-date-column-and-current-date-in/m-p/692745#M211100</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/316224"&gt;@Saurabh_Rana&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have customer policy data where customer can have multiple policies against his/her name along with the policy start date. I want to derive the time in years since the customer is associated with us so basically I want to find time between the policy start date of the first policy and the current date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example-&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Input&lt;/P&gt;
&lt;PRE&gt;Customer_Name Policy_Start_Date
cust_1        20/10/2019
cust_2        20/10/2018

Output&amp;nbsp;

Customer_Name Customer_Since
cust_1        1 Year
cust_2        2 Year&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What have you tried so far? You are talking about having multiple policies per customer, but in your example data there is only one observation for each customer. Please take care that the data you post matches what you have as close as possible. Also post the data in usable form.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 05:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-maximum-difference-between-date-column-and-current-date-in/m-p/692745#M211100</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-10-20T05:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Find maximum difference between date column and current date in years.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-maximum-difference-between-date-column-and-current-date-in/m-p/692746#M211101</link>
      <description>I have updated the example</description>
      <pubDate>Tue, 20 Oct 2020 05:36:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-maximum-difference-between-date-column-and-current-date-in/m-p/692746#M211101</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2020-10-20T05:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Find maximum difference between date column and current date in years.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-maximum-difference-between-date-column-and-current-date-in/m-p/692752#M211103</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;I have updated the example&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Good. Now try the proposed solutions.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 06:00:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-maximum-difference-between-date-column-and-current-date-in/m-p/692752#M211103</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-10-20T06:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: Find maximum difference between date column and current date in years.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-maximum-difference-between-date-column-and-current-date-in/m-p/692753#M211104</link>
      <description>&lt;P&gt;Untested, the data is still not in usable form.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have out=sorted;
  by customer_name policy_start_date;
run;

data want;
  set sorted;
  by customer_name;

  if first.customer_name;
  years = yrdif(policy_start_date, today());
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You may want to look at the documentation of &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p1pmmr2dtec32an1vbsqmm3abil5.htm&amp;amp;locale=en" target="_self"&gt;yrdif&lt;/A&gt;, the function has a third parameter that could be used to tweak the result.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 06:01:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-maximum-difference-between-date-column-and-current-date-in/m-p/692753#M211104</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-10-20T06:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: Find maximum difference between date column and current date in years.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-maximum-difference-between-date-column-and-current-date-in/m-p/692796#M211123</link>
      <description>&lt;P&gt;SQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select
    customer_name,
    intck('year',min(policy_start_date),today(),'c') as years
  from have
  group by customer_name
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Modify the last parameter of INTCK as needed.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 09:39:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-maximum-difference-between-date-column-and-current-date-in/m-p/692796#M211123</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-20T09:39:50Z</dc:date>
    </item>
  </channel>
</rss>

