title: SAS comparing two dates
body: <p>i have a sas file which looks like</p>
  <pre><code>date1       date2       date3       comp
  
  20201208    20110201    20120201  
  20201208    20200101    20210201
  </code></pre>
  <p>all date are numeric with format yymmddn8. and comp is a text type.</p>
  <p>Now I want to fill comp with 1 or 0 like</p>
  <pre><code>if date2 &lt; date1 &lt; date3 then comp=1; else comp=0;
  </code></pre>
  <p>but it don<code>t work. I always get </code>1` even if the condition is true.</p>
  <p>Progam (from comments)</p>
  <pre><code>data kl.kl_neukunde; 
    set kl.kl01; 
    format tday yymmddn8. ; 
    format date_nk yymmddn8. ; 
    format date_nk_12mon yymmddn8. ; 
    tday=today(); 
    date_nk = put(input(erste_besuch, ddmmyy10.), yymmdd8.)*1;
    date_nk_12mon = date_nk + 10000; 
    if date_nk='' then date_nk=0; 
    if date_nk_12mon='' then date_nk_12mon=0;
    if date_nk &lt; tday &lt; date_nk_12mon then neukunde=&quot;1&quot;; 
  </code></pre>
  <p>Thx</p>