Check for valid dates using SAS macro
<p>I have written a macro to check for invalid dates and set it to '11111111', but got an unexpected  <strong>NOTE: Invalid argument to function INPUT</strong>. The reason for the note is, source data has date "0212-04-26" which is beyond the SAS dates ranging A.D. 1582 to A.D. 19,900. So now I'm looking to check for invalid date without any message`.</p>

<p>My Code:</p>

<pre><code>  %macro chkdate(datefld=, num_date=) ;
  /* invalid date gets set to '11111111'    */
    if &amp;datefld ne '0001-01-01' then do ;
     t_date = input(compress(&amp;datefld, '-'), yymmdd8.) ;
       if t_date eq . then do ;
          %errors( key_desc=Invalid Date, fname=&amp;datefld,)
          &amp;datefld = '11111111' ;
       end;
    end;
  %mend chkdate ;
</code></pre>

<p>thanks</p>