<?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 date in MONYY format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600231#M173439</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;Hi Reeza, this works except in those cases where the difference is in months. Say the appl_date is 'MAY2019' and the doc_date is 'APR2019', then it returns 0. How can I address such cases?&lt;/P&gt;</description>
    <pubDate>Wed, 30 Oct 2019 01:38:08 GMT</pubDate>
    <dc:creator>PDevi</dc:creator>
    <dc:date>2019-10-30T01:38:08Z</dc:date>
    <item>
      <title>Difference between date in MONYY format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600201#M173420</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table that has two dates as below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id&amp;nbsp; &amp;nbsp; &amp;nbsp; appl_date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; doc_date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; SEP2013&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AUG2013&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; JAN2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NOV2018&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; MAY2017&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; JAN2015&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The 'appl_date' is a character field and the 'doc_date' is a date field in MONYY7. format. I need to keep only those records that have a gap of 2 or less years. In the above example, I should be excluding id #3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 22:35:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600201#M173420</guid>
      <dc:creator>PDevi</dc:creator>
      <dc:date>2019-10-29T22:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between date in MONYY format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600205#M173423</link>
      <description>&lt;P&gt;You need to convert your appl_date to a sas date. &lt;BR /&gt;Assuming the day doesn't matter, use :&lt;BR /&gt;&lt;BR /&gt;dif = intck('year', input(appl_date, monyy5.), doc_date);&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 01:19:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600205#M173423</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-30T01:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between date in MONYY format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600206#M173424</link>
      <description>&lt;P&gt;So, you need to make a new variable (call it APPDATE) with the numeric date value corresponding to the text in APPL_DATE.&amp;nbsp; To be&lt;/P&gt;
&lt;P&gt;a date value you need more than SEP2013, which is missing the day number. &amp;nbsp; So you can prepend a "01" to APPL_DATE, and then apply the INPUT function to that string using the DATE9. informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can compare using the SAS INTCK function to count the number of months between APPDATE and DOC_DATE as your&amp;nbsp; filter mechanism.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 22:45:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600206#M173424</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-29T22:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between date in MONYY format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600208#M173426</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input id      (appl_date          doc_date ) (:monyy7.);
 format  appl_date          doc_date monyy7.;
cards;
1      SEP2013           AUG2013
2      JAN2019           NOV2018
3      MAY2017          JAN2015
;

data want;
set have;
if yrdif(doc_date,appl_date,'ACT/ACT')&amp;lt;=2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Oh your is char field, so&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input id      (appl_date          doc_date ) ($);
cards;
1      SEP2013           AUG2013
2      JAN2019           NOV2018
3      MAY2017          JAN2015
;

data want;
set have;
if yrdif(input(doc_date,monyy7.),input(appl_date,monyy7.),'ACT/ACT')&amp;lt;=2;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 22:56:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600208#M173426</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-10-29T22:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between date in MONYY format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600231#M173439</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;Hi Reeza, this works except in those cases where the difference is in months. Say the appl_date is 'MAY2019' and the doc_date is 'APR2019', then it returns 0. How can I address such cases?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 01:38:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600231#M173439</guid>
      <dc:creator>PDevi</dc:creator>
      <dc:date>2019-10-30T01:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between date in MONYY format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600234#M173441</link>
      <description>You asked for two years or less, 0 is less than 2 and it hasn't completed a year so not sure how that doesn't answer your question. &lt;BR /&gt;&lt;BR /&gt;If you want months instead, switch the interval from year to months and change your criteria to be 24 months instead.</description>
      <pubDate>Wed, 30 Oct 2019 02:06:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600234#M173441</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-30T02:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between date in MONYY format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600266#M173456</link>
      <description>&lt;P&gt;Please try the below code as well,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id appl_date$ doc_date:date9. ;
if not (intck('year', input(cats('01',appl_date), date9.),doc_date ) &amp;lt;=-2);
format  doc_date monyy7.;
cards;      
1 SEP2013 01AUG2013
2 JAN2019 01NOV2018
3 MAY2017 01JAN2015
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Oct 2019 06:05:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600266#M173456</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-10-30T06:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between date in MONYY format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600425#M173557</link>
      <description>You are right, I should have been more explicit in what I was looking for. Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;</description>
      <pubDate>Wed, 30 Oct 2019 15:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600425#M173557</guid>
      <dc:creator>PDevi</dc:creator>
      <dc:date>2019-10-30T15:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between date in MONYY format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600465#M173574</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; Thanks. This worked perfectly for what I was looking to do.</description>
      <pubDate>Wed, 30 Oct 2019 17:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600465#M173574</guid>
      <dc:creator>PDevi</dc:creator>
      <dc:date>2019-10-30T17:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between date in MONYY format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600466#M173575</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt; Thank you.</description>
      <pubDate>Wed, 30 Oct 2019 17:18:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600466#M173575</guid>
      <dc:creator>PDevi</dc:creator>
      <dc:date>2019-10-30T17:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between date in MONYY format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600467#M173576</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt; Thanks</description>
      <pubDate>Wed, 30 Oct 2019 17:19:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-date-in-MONYY-format/m-p/600467#M173576</guid>
      <dc:creator>PDevi</dc:creator>
      <dc:date>2019-10-30T17:19:24Z</dc:date>
    </item>
  </channel>
</rss>

