<?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 Difference of SAS dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Difference-of-SAS-dates/m-p/543649#M150300</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working with SAS dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following data which represent the opening and closing dates of some businesses.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Opening_Date	Closing_Date
19/02/1955	19/02/2020
23/03/1955	23/03/2025
23/03/1955	23/03/2025
28/11/1956	28/11/2026
13/04/1954	13/04/2019
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dates in the SAS data set are character so I used the following code to convert them in numerical form:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Opening_Date_New = input(Opening_Date, ddmmyy10.);

Closing_Date_New = input(Closing_Date, ddmmyy10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Later in the program, based on some conditions I want to create an Expected_Closing_Date, which is calculated by adding 80 years to the Opening_Date_New. For that I use the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Expected_Closing_Date = intnx("year", Opening_Date_New, 80, 'sameday');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In a Data Step I format the dates by using the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format Opening_Date_New yymmdd10. Expected_Closing_Date yymmdd10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I end up having the data attached, which look like as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Opening_Date    Closing_Date         Opening_Date_New    Expected_Closing_Date
19/02/1955	19/02/2020	     19/02/1955	    19/02/2035
23/03/1955	23/03/2025	     23/03/1955	    23/03/2035
23/03/1955	23/03/2025	     23/03/1955	    23/03/2035
28/11/1956	28/11/2026	     28/11/1956	    28/11/2036
13/04/1954	13/04/2019	     13/04/1954	    13/04/2034
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to calculated the difference between the Opening_Date_New and Expected_Closing_Date but I am getting an error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; &lt;BR /&gt;set have;
Diff = intnx('year', Opening_Date_New, Expected_Closing_Date);
run;&lt;BR /&gt;&lt;BR /&gt;NOTE: Invalid argument to function INTNX('year',-1777,27443) at line 139 column 8.&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Any help please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Mar 2019 20:20:03 GMT</pubDate>
    <dc:creator>Zatere</dc:creator>
    <dc:date>2019-03-15T20:20:03Z</dc:date>
    <item>
      <title>Difference of SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-of-SAS-dates/m-p/543649#M150300</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working with SAS dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following data which represent the opening and closing dates of some businesses.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Opening_Date	Closing_Date
19/02/1955	19/02/2020
23/03/1955	23/03/2025
23/03/1955	23/03/2025
28/11/1956	28/11/2026
13/04/1954	13/04/2019
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dates in the SAS data set are character so I used the following code to convert them in numerical form:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Opening_Date_New = input(Opening_Date, ddmmyy10.);

Closing_Date_New = input(Closing_Date, ddmmyy10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Later in the program, based on some conditions I want to create an Expected_Closing_Date, which is calculated by adding 80 years to the Opening_Date_New. For that I use the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Expected_Closing_Date = intnx("year", Opening_Date_New, 80, 'sameday');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In a Data Step I format the dates by using the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format Opening_Date_New yymmdd10. Expected_Closing_Date yymmdd10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I end up having the data attached, which look like as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Opening_Date    Closing_Date         Opening_Date_New    Expected_Closing_Date
19/02/1955	19/02/2020	     19/02/1955	    19/02/2035
23/03/1955	23/03/2025	     23/03/1955	    23/03/2035
23/03/1955	23/03/2025	     23/03/1955	    23/03/2035
28/11/1956	28/11/2026	     28/11/1956	    28/11/2036
13/04/1954	13/04/2019	     13/04/1954	    13/04/2034
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to calculated the difference between the Opening_Date_New and Expected_Closing_Date but I am getting an error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; &lt;BR /&gt;set have;
Diff = intnx('year', Opening_Date_New, Expected_Closing_Date);
run;&lt;BR /&gt;&lt;BR /&gt;NOTE: Invalid argument to function INTNX('year',-1777,27443) at line 139 column 8.&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Any help please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2019 20:20:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-of-SAS-dates/m-p/543649#M150300</guid>
      <dc:creator>Zatere</dc:creator>
      <dc:date>2019-03-15T20:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: Difference of SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-of-SAS-dates/m-p/543655#M150302</link>
      <description>&lt;P&gt;You are using the incorrect function.&amp;nbsp; Use the following instead.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Diff &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;STRONG&gt; &lt;SPAN class="token function"&gt;intck&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'year'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; Opening_Date_New&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;Ex&lt;/SPAN&gt;pected_Closing_Date&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2019 20:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-of-SAS-dates/m-p/543655#M150302</guid>
      <dc:creator>PabloNogueras</dc:creator>
      <dc:date>2019-03-15T20:43:08Z</dc:date>
    </item>
  </channel>
</rss>

