<?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: Check to see if this date is between a start date and end date and produce a result in new colum in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739909#M231010</link>
    <description>&lt;P&gt;so the data set dor is in yymmddn8. format. I want to see if this DOR value is in between&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//&lt;/P&gt;&lt;P&gt;One of the values has DOR that is 20161101 when I run the command, match does not appear as it should?&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ( &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'01FEB16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;lt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;DOR &lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;lt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'31DEC16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; )&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; pzone=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"match"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 07 May 2021 21:49:36 GMT</pubDate>
    <dc:creator>kmin87</dc:creator>
    <dc:date>2021-05-07T21:49:36Z</dc:date>
    <item>
      <title>Check to see if this date is between a start date and end date and produce a result in new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739905#M231007</link>
      <description>&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;//&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test3;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;Hello Nov 01 2016 is between Feb and DEc 2016 but it does not produce match in the pzone column. Is there something I am doing incorrectly? Any assistance would be greatly appreciated.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; dor &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;yymmddn8.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;dor=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;161101&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; pzone $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;10&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;//&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ( &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'01FEB16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;lt;=DOR &amp;lt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'31DEC16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; ) &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; pzone=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"match"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 21:33:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739905#M231007</guid>
      <dc:creator>kmin87</dc:creator>
      <dc:date>2021-05-07T21:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if this date is between a start date and end date and produce a result in new colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739906#M231008</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dor=161101;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;does not create a valid SAS date. Instead, use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dor='01NOV2016'd;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which does create a valid SAS date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 21:39:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739906#M231008</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-05-07T21:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if this date is between a start date and end date and produce a result in new colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739909#M231010</link>
      <description>&lt;P&gt;so the data set dor is in yymmddn8. format. I want to see if this DOR value is in between&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//&lt;/P&gt;&lt;P&gt;One of the values has DOR that is 20161101 when I run the command, match does not appear as it should?&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ( &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'01FEB16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;lt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;DOR &lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;lt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'31DEC16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; )&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; pzone=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"match"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 21:49:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739909#M231010</guid>
      <dc:creator>kmin87</dc:creator>
      <dc:date>2021-05-07T21:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if this date is between a start date and end date and produce a result in new colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739910#M231011</link>
      <description>&lt;P&gt;Do I need to convert the DOR column that is in yymmddn8. format to another format to see if it can be compared to the 'DDMMYY'd format?&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 21:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739910#M231011</guid>
      <dc:creator>kmin87</dc:creator>
      <dc:date>2021-05-07T21:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if this date is between a start date and end date and produce a result in new colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739912#M231013</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/376137"&gt;@kmin87&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;//&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test3;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;Hello Nov 01 2016 is between Feb and DEc 2016 but it does not produce match in the pzone column. Is there something I am doing incorrectly? Any assistance would be greatly appreciated.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; dor &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;yymmddn8.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;dor=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;161101&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; pzone $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;10&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;//&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ( &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'01FEB16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;lt;=DOR &amp;lt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'31DEC16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; ) &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; pzone=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"match"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What you are doing "incorrectly" is using a random number and treating it as a "date".&lt;/P&gt;
&lt;P&gt;If you look at the formatted value for that example value of DOR you will see that it corresponds to dor=2401-01-29.&lt;/P&gt;
&lt;P&gt;If 161101 is supposed to be in November to compare it with actual date values you have to make it into a date. One way looks like:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  dor=161101;
  actualdate = input(put(dor,6.),yymmdd6.);
  put actualdate= date9.;
run;&lt;/PRE&gt;
&lt;P&gt;which will yield: actualdate=01NOV2016.&lt;/P&gt;
&lt;P&gt;You can avoid such by reading your original data correctly. If you are&amp;nbsp; using Proc Import it generally not "guess" that a value like that looks like a date, partially because it could be confused with 16Nov2021 (read as ddmmyy6). If you are reading the value with a data step then you should change the informat for the variable(s) to yymmdd or other that matches the content.&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 22:00:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739912#M231013</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-07T22:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if this date is between a start date and end date and produce a result in new colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739913#M231014</link>
      <description>&lt;P&gt;It's not a matter of format, it's a matter of data understanding.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS stores dates as the number of days from January 1, 1960.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;So the date November 01, 2016 is mathematically: 20,759.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS then uses the format, YYMMDD to display that as 2016-11-01&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dor=161101;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You're creating a date that's actually 161, 101 days from January 1, 1970 which is actually January 24, 2401.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dor="01Jan1960"d +161101;
format dor yymmddn8.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To create a SAS date you must provide it as a date literal using either the DATE7 or DATE9 format, use a MDY() function or INPUT().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test3;

dor=mdy(11, 1, 2016); output;
dor = input("161101", yymmdd6.); output;
dor = "01Nov2016"d; output;
format dor yymmddn8.;


run;

proc print data=test3;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a great, but longer and in depth, reference for dates and times in SAS&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/376137"&gt;@kmin87&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;//&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test3;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;Hello Nov 01 2016 is between Feb and DEc 2016 but it does not produce match in the pzone column. Is there something I am doing incorrectly? Any assistance would be greatly appreciated.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; dor &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;yymmddn8.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;dor=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;161101&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; pzone $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;10&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;//&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ( &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'01FEB16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;lt;=DOR &amp;lt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'31DEC16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; ) &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; pzone=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"match"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, note that the DO/END are not required in your code. This would be sufficient. It doesn't really make sense to have an assignment (pzone="match" as part of a DO). DO is usually used to loop or conditionally execute and you don't seem to be doing that. Better examples and explanations &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/basess/p0pcj5ajwyngron1wlsq0tet0hce.htm" target="_self"&gt;here&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if ( '01FEB16'd &amp;lt;=DOR &amp;lt;='31DEC16'd ) then pzone="match";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 May 2021 22:07:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739913#M231014</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-07T22:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if this date is between a start date and end date and produce a result in new colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739914#M231015</link>
      <description>&lt;P&gt;//&lt;/P&gt;&lt;P&gt;OK so I am pulling this from a dataset that has a DOR column in YYYYMMDDn8. format&lt;/P&gt;&lt;P&gt;One of the values in that columns is 20161101.&lt;/P&gt;&lt;P&gt;if the DOR is between 01feb2016 and 31dec2016 then it would be a match&lt;/P&gt;&lt;P&gt;if DOR less than or equal to 31DEC16 then it will be match2&lt;/P&gt;&lt;P&gt;FOR EXAMPLE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The DOR colum/variable in the dataset has numerous rows with different dates in the YYYYMMDDn8. format one of them is 20161101. When I run it, it does not produce match&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test3;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;set lib.test_data(keep dor);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;dummy $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;10&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ( &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'01FEB16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;lt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'01NOV16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;lt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'31DEC16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; ) &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="2"&gt;dummy=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"match"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; DOR &amp;lt;= &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'31DEC16'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; dummy=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"match2"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;//&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 22:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739914#M231015</guid>
      <dc:creator>kmin87</dc:creator>
      <dc:date>2021-05-07T22:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if this date is between a start date and end date and produce a result in new colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739915#M231016</link>
      <description>//&lt;BR /&gt;&lt;BR /&gt;OK so I am pulling this from a dataset that has a DOR column in YYYYMMDDn8. format&lt;BR /&gt;&lt;BR /&gt;One of the values in that columns is 20161101.&lt;BR /&gt;&lt;BR /&gt;if the DOR is between 01feb2016 and 31dec2016 then it would be a match&lt;BR /&gt;&lt;BR /&gt;if DOR less than or equal to 31DEC16 then it will be match2&lt;BR /&gt;&lt;BR /&gt;FOR EXAMPLE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The DOR colum/variable in the dataset has numerous rows with different dates in the YYYYMMDDn8. format one of them is 20161101. When I run it, it does not produce match&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data test3;&lt;BR /&gt;&lt;BR /&gt;set lib.test_data(keep dor);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;length dummy $10;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if ( '01FEB16'd &amp;lt;='01NOV16'd &amp;lt;='31DEC16'd ) then dummy="match";&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;else if DOR &amp;lt;= '31DEC16'd then dummy="match2";&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;//&lt;BR /&gt;</description>
      <pubDate>Fri, 07 May 2021 22:14:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739915#M231016</guid>
      <dc:creator>kmin87</dc:creator>
      <dc:date>2021-05-07T22:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if this date is between a start date and end date and produce a result in new colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739917#M231018</link>
      <description>Your IF condition doesn't refer to your DOR variable, everything is hardcoded, is that what you intended? It will always be TRUE so your ELSE never gets evaluated.</description>
      <pubDate>Fri, 07 May 2021 22:32:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739917#M231018</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-07T22:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if this date is between a start date and end date and produce a result in new colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739919#M231020</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/376137"&gt;@kmin87&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;//&lt;/P&gt;
&lt;P&gt;OK so I am pulling this from a dataset that has a DOR column in YYYYMMDDn8. format&lt;/P&gt;
&lt;P&gt;One of the values in that columns is 20161101.&lt;/P&gt;
&lt;P&gt;if the DOR is between 01feb2016 and 31dec2016 then it would be a match&lt;/P&gt;
&lt;P&gt;if DOR less than or equal to 31DEC16 then it will be match2&lt;/P&gt;
&lt;P&gt;FOR EXAMPLE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DOR colum/variable in the dataset has numerous rows with different dates in the YYYYMMDDn8. format one of them is 20161101. When I run it, it does not produce match&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test3;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;set lib.test_data(keep dor);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;dummy $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;10&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ( &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'01FEB16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;lt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'01NOV16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;lt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'31DEC16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; ) &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="2"&gt;dummy=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"match"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; DOR &amp;lt;= &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'31DEC16'd&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; dummy=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"match2"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;//&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Did you run proc contents on the data set and that shows a format of YYMMDDn8. attached to the DOR variable?&lt;/P&gt;
&lt;P&gt;The value you show in the first post is only 6 digits. YYMMDDn8 looks like 20161101 when formatting a value of 01NOV2016, not 161101. &amp;lt;=&lt;STRONG&gt;6&lt;/STRONG&gt; digits, not 8. So something inconsistent is going on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run this code:&lt;/P&gt;
&lt;PRE&gt;data test3;
   set lib.test_data(keep dor);
run;

proc print data=test3;
   format dor yymmddn8.;
run;&lt;/PRE&gt;
&lt;P&gt;Then show us some of the results from proc print.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many people see numbers and assume they are a "date" with a given format. Quite often that is not the case.&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 22:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739919#M231020</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-07T22:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if this date is between a start date and end date and produce a result in new colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739922#M231022</link>
      <description>I am not sure what you mean. I want to compare the values in the dor&lt;BR /&gt;variables/columns to a start and end date.&lt;BR /&gt;</description>
      <pubDate>Fri, 07 May 2021 23:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739922#M231022</guid>
      <dc:creator>kmin87</dc:creator>
      <dc:date>2021-05-07T23:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if this date is between a start date and end date and produce a result in new colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739944#M231036</link>
      <description>&lt;P&gt;Here your code fixed by replacing &lt;SPAN&gt;'01NOV16'd with variable DOR.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test3;
  set lib.test_data(keep dor);
  length dummy $10;

  if ( '01FEB16'd &amp;lt;= DOR &amp;lt;='31DEC16'd ) then
    dummy="match";
  else if DOR &amp;lt;= '31DEC16'd then
    dummy="match2";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS stores dates in numerical variables as the count of days since 1/1/1960. Such a number is of course not human readable as a date and that's why you also apply a date format to the variable so when you print the value it becomes human readable.&lt;/P&gt;
&lt;P&gt;The format applied does not change the internal value stored (the count of days) and has no impact on any calculations or conditions. There the internal value (count of days) gets used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;&lt;EM&gt;d&lt;/EM&gt;&amp;nbsp;in SAS syntax like&amp;nbsp;&lt;CODE class=" language-sas"&gt;'31DEC16'd&lt;/CODE&gt;&amp;nbsp;let's you write a date in the form of a 'ddmonyy&amp;lt;yy&amp;gt;'d string. Using the &lt;EM&gt;d&lt;/EM&gt; instructs SAS that this string is to be treated as a date and SAS will convert the string to a SAS date value prior of using it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have a look at below. May be that will make it clearer to you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Printing the SAS Date value with format best32. shows you the value as the count of days since 1/1/1960. Also note that variable SASDateValue is of type numeric.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  length SASDateValue 8;
  SASDateValue='01FEB16'd;
  put 
    "SAS Date Value printed using different formats"
    / 'best32.  ' SASDateValue best32. -l
    / 'date9.   ' SASDateValue date9. -l
    / 'yymmddn. ' SASDateValue yymmddn. -l
    ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;SAS Date Value printed using different formats
best32.  20485                           
date9.   01FEB2016
yymmddn. 20160201&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your initial post you pass to variable dor a value of 161101 -&amp;nbsp;&lt;FONT face="Courier New" size="2"&gt;dor=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;161101&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;For SAS this was the count of days since 1/1/1960 and though this date was clearly outside of the range you've tested for.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  length SASDateValue 8;
  SASDateValue=161101;
  put 
    "SAS Date Value printed using different formats"
    / 'best32.  ' SASDateValue best32. -l
    / 'date9.   ' SASDateValue date9. -l
    / 'yymmddn. ' SASDateValue yymmddn. -l
    ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;SAS Date Value printed using different formats
best32.  161101                          
date9.   29JAN2401
yymmddn. 24010129&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 May 2021 03:35:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739944#M231036</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-05-08T03:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if this date is between a start date and end date and produce a result in new colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739959#M231048</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/376137"&gt;@kmin87&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;The DOR colum/variable in the dataset has numerous rows with different dates in the YYYYMMDDn8. format one of them is 20161101. When I run it, it does not produce match&lt;BR /&gt;data test3;&lt;BR /&gt;set lib.test_data(keep dor);&lt;BR /&gt;length dummy $10;&lt;BR /&gt;if ( '01FEB16'd &amp;lt;='01NOV16'd &amp;lt;='31DEC16'd ) then dummy="match";&lt;BR /&gt;else if DOR &amp;lt;= '31DEC16'd then dummy="match2";&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now you have introduced what appears to be a logical error and programming errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if ( '01FEB16'd &amp;lt;='01NOV16'd &amp;lt;='31DEC16'd ) then dummy="match";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This does not use the variable DOR. So regardless of the value in DOR, the variable dummy will be assigned the value "match" from this statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else if DOR &amp;lt;= '31DEC16'd then dummy="match2";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and this statement will never execute, because the IF (which comes directly before the ELSE) is always true.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you mean to write:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if ( '01FEB16'd &amp;lt;=DOR &amp;lt;='31DEC16'd ) then dummy="match";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in which case the value of DOR is used. However, if the value of DOR is the integer 20161101, then SAS will not recognize this as a valid SAS date, and it will still not set the value of variable dummy to "match".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, is DOR formatted somehow? (Use PROC CONTENTS to find out). If PROC CONTENTS says that DOR is unformatted, then you would need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if ( '01FEB16'd &amp;lt;=input(put(DOR,8.),yymmdd8.) &amp;lt;='31DEC16'd ) then dummy="match";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If PROC CONTENTS says that DOR is formatted as yymmdd8. then just placing DOR into the expression (which I did above) will work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly, you still have other programming or logical errors. Your set statement needs an equal sign&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set lib.test_data(keep=dor);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and your logic is wrong too, if DOR is not between '01FEB16'd and '31DEC16'd, then the ELSE statement really will give you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;else if DOR &amp;lt; '01FEB16'd then dummy="match2";&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;because when DOR is between those other dates you get dummy="match" and the ELSE will not execute. If DOR is after '31DEC16'd then variable dummy does not get assigned a value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/376137"&gt;@kmin87&lt;/a&gt;, &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;from now on, 100% of the time, without fail&lt;/STRONG&gt;&lt;/FONT&gt;, provide us with a representative portion of your actual data, following these instructions: &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/&lt;/A&gt; This will lead to quicker and better answers, and save all of us a lot of time. I consider this mandatory, do not present us with SAS problems without also providing a portion of the data as I have described.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 May 2021 13:45:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/739959#M231048</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-05-08T13:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if this date is between a start date and end date and produce a result in new colum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/740019#M231085</link>
      <description>&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ( &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'01FEB16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;lt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'01NOV16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;lt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;'31DEC16'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; ) &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="2"&gt;dummy=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"match"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;This is your code and test. It does not reference your variables, since there's no reference to DOR. So I assume this is not what you intended to do.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;FYI - a very good way to ensure your code is logical when you start out is to comment every line with what you expect is happening. This helps you&amp;nbsp;ensure that your code is working as expected.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/376137"&gt;@kmin87&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I am not sure what you mean. I want to compare the values in the dor&lt;BR /&gt;variables/columns to a start and end date.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 May 2021 01:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-this-date-is-between-a-start-date-and-end-date/m-p/740019#M231085</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-09T01:44:12Z</dc:date>
    </item>
  </channel>
</rss>

