<?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: Comparing the dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Comparing-the-dates/m-p/923168#M363471</link>
    <description>&lt;P&gt;When you say "doesn't work" I assume you mean the code runs without errors or warnings in the log, but you're surprised by the result?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is your intent for this code?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to select records with date on or before the April 1, 2024, don't use the MONTH function, try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if   "Date de réception"n &amp;lt;= "01APR2024"d ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The MONTH() function will return 1-12, which is probably not what you want.&amp;nbsp; When you use the MONTH function, this comparison will always be true.&lt;/P&gt;</description>
    <pubDate>Fri, 05 Apr 2024 13:19:43 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2024-04-05T13:19:43Z</dc:date>
    <item>
      <title>Comparing the dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-the-dates/m-p/923167#M363470</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm wondering why this data comparing doesn't work (I have also the date&amp;gt; 01/04/2024 in base finale)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data base_finale;
	set base2;
	if   month("Date de réception"n)&amp;lt;="01APR2024"d;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The format of coulmn is&amp;nbsp;&lt;CODE class=" language-sas"&gt;"Date de réception"n&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASdevAnneMarie_0-1712322593042.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95242i0A7D7C43E295BC98/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASdevAnneMarie_0-1712322593042.png" alt="SASdevAnneMarie_0-1712322593042.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thank you !&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2024 13:11:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-the-dates/m-p/923167#M363470</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2024-04-05T13:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing the dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-the-dates/m-p/923168#M363471</link>
      <description>&lt;P&gt;When you say "doesn't work" I assume you mean the code runs without errors or warnings in the log, but you're surprised by the result?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is your intent for this code?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to select records with date on or before the April 1, 2024, don't use the MONTH function, try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if   "Date de réception"n &amp;lt;= "01APR2024"d ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The MONTH() function will return 1-12, which is probably not what you want.&amp;nbsp; When you use the MONTH function, this comparison will always be true.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2024 13:19:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-the-dates/m-p/923168#M363471</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-04-05T13:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing the dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-the-dates/m-p/923171#M363473</link>
      <description>&lt;P&gt;The MONTH function will return a value of 1 to 12 when given a numeric (hopefully date) value or missing if the argument is missing. So you get a return of at most 12.&amp;nbsp; The date 01APR2024 has a numeric value of 23467.&lt;/P&gt;
&lt;P&gt;So any result from the Month function will be much less than 23467.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you haven't encountered it before, missing is always less than any non-missing value.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2024 13:42:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-the-dates/m-p/923171#M363473</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-05T13:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing the dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-the-dates/m-p/923192#M363480</link>
      <description>&lt;P&gt;Are you looking for any row where the comparison date is from the same or previous month, or should the two dates only be max one month apart? Below code should give you an idea of the options.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data base2;
  format "Date de réception"n ddmmyy10.;
  "Date de réception"n='20mar2024'd; output;
  "Date de réception"n='20may2024'd; output;
  "Date de réception"n='12jan2023'd; output;
run;

run;
data base_finale;
	set base2;
  /* if intck('month',"Date de réception"n,"01APR2024"d) in (0,1); */
  interval_1=intck('month',"Date de réception"n,"01APR2024"d);
  interval_2=intck('month',"Date de réception"n,"01APR2024"d,'c');
run;

proc print data=base_finale;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1712329218231.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95246iB1E2CD836008DABF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1712329218231.png" alt="Patrick_0-1712329218231.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2024 15:00:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-the-dates/m-p/923192#M363480</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-04-05T15:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing the dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-the-dates/m-p/923348#M363526</link>
      <description>Thank you Quentin.</description>
      <pubDate>Sun, 07 Apr 2024 18:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-the-dates/m-p/923348#M363526</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2024-04-07T18:58:04Z</dc:date>
    </item>
  </channel>
</rss>

