<?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: Why is it not returning null values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857614#M338871</link>
    <description>&lt;P&gt;So something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   (open between &amp;amp;date1 and &amp;amp;date2) 
or (close between &amp;amp;date1 and &amp;amp;date2)
or (missing(close) and open &amp;gt; &amp;amp;date3)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 07 Feb 2023 17:33:27 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-02-07T17:33:27Z</dc:date>
    <item>
      <title>Why is it not returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857568#M338841</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;Please see the below codes. I’m trying to extract the data between those dates and that if there is a null value in both closing and open date. Is there a way to specify that in the below codes?&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Proc sql;&lt;BR /&gt;Create or replace table Cais as&lt;BR /&gt;Select sourcecode, opendate, closingdate from Expin where&lt;BR /&gt;sourcecode in (‘125’, ‘154’, ‘264’) and opendate &amp;gt;= ‘2021-03-01’ and closingdate &amp;lt;= ‘2023-02-07’ and closingdate is null ;&lt;BR /&gt;Quit;&lt;BR /&gt;&lt;BR /&gt;I</description>
      <pubDate>Tue, 07 Feb 2023 15:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857568#M338841</guid>
      <dc:creator>Coding4you</dc:creator>
      <dc:date>2023-02-07T15:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why is it not returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857574#M338846</link>
      <description>&lt;P&gt;Your variables OPENDATE and CLOSINGDATE must be character strings for this to work. Furthermore CLOSINGDATE cannot satisfy both conditions&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;closingdate &amp;lt;= '2023-02-07' and closingdate is null&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;unless closingdate is null, I'm sure that's not what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe (maybe maybe maybe) you mean this (in which case opendate and closingdate must be numeric):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;and opendate &amp;gt;= '03JAN2021'd and closingdate &amp;lt;= '07FEB2023'd&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but since you didn't really explain what you want, that's a big guess, and there's no way to incorporate the idea that closingdate is null into this logic. Can you give examples of what this is supposed to do, when it is supposed to succeed and when it is supposed to fail?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly, you have "curly" quotes in your code, that will never work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 16:04:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857574#M338846</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-07T16:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why is it not returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857593#M338859</link>
      <description>Thank you for your speedy response!&lt;BR /&gt;&lt;BR /&gt;Sorry for the confusion.&lt;BR /&gt;&lt;BR /&gt;What I was trying to do was extract all the source code that was between those dates. However, if I ran the code where opendate &amp;gt;= '03JAN2021'and closingdate &amp;lt;= '07FEB2023’ it will only provide the dates that are within those specific dates, which is correct. What I wanted to include was that when there are records where there are null values in the closing date but not the open date, and vice versa within the same step, which won't work as it wouldn't be able to satisfy both conditions as mentioned below.&lt;BR /&gt;&lt;BR /&gt;i was thinking whether there's a quick way to get all that information in a few steps from the same table.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;i hope they</description>
      <pubDate>Tue, 07 Feb 2023 16:36:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857593#M338859</guid>
      <dc:creator>Coding4you</dc:creator>
      <dc:date>2023-02-07T16:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: Why is it not returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857601#M338862</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/437191"&gt;@Coding4you&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you for your speedy response!&lt;BR /&gt;&lt;BR /&gt;Sorry for the confusion.&lt;BR /&gt;&lt;BR /&gt;What I was trying to do was extract all the source code that was between those dates. However, if I ran the code where opendate &amp;gt;= '03JAN2021'and closingdate &amp;lt;= '07FEB2023’ it will only provide the dates that are within those specific dates, which is correct. What I wanted to include was that when there are records where there are null values in the closing date but not the open date, and vice versa within the same step, which won't work as it wouldn't be able to satisfy both conditions as mentioned below.&lt;BR /&gt;&lt;BR /&gt;i was thinking whether there's a quick way to get all that information in a few steps from the same table.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;i hope they&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are you looking to see if the two intervals, (OPENINGDATE to CLOSINGDATE) and ('03JAN2021'd to '07FEB2023'd) overlap at all?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or are you trying to see if one is totally contained in the other?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 16:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857601#M338862</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-07T16:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Why is it not returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857603#M338863</link>
      <description>&lt;P&gt;Take a piece of paper and draw a line with endpoints A and B.&amp;nbsp; Now under it draw more lines with end points labeled C and D.&amp;nbsp; Draw one where C to D is totally inside of A to B.&amp;nbsp; Draw one where it is totally before, another with it after.&amp;nbsp; Then draw one where only C is between A and B and one where only D is between A and B.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Period              A-----------------B
Inside                 C-----D
Before        C--D
After                                       C---D
left          C----------D
right                             C----------D
&lt;/PRE&gt;
&lt;P&gt;So which of these do you want to detect?&lt;/P&gt;
&lt;P&gt;Also what do want to do when either of the two dataset variables are missing?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To select only the INSIDE example then use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;(C between A and B) AND (D between A and B)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To select any overlap use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;(C between A and B) OR (D between A and B)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 17:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857603#M338863</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-07T17:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: Why is it not returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857611#M338868</link>
      <description>Yes I’m trying to extract anything that fall between those dates and if&lt;BR /&gt;closing date is null when open date &amp;gt;= ‘2021-03-31’ if that make sense.</description>
      <pubDate>Tue, 07 Feb 2023 17:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857611#M338868</guid>
      <dc:creator>Coding4you</dc:creator>
      <dc:date>2023-02-07T17:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Why is it not returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857613#M338870</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;However, if I ran the code where opendate &amp;gt;= '03JAN2021'and closingdate &amp;lt;= '07FEB2023’ it will only provide the dates that are within those specific dates, which is correct. What I wanted to include was that when there are records where there are null values in the closing date but not the open date&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;How about this:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where (opendate&amp;gt;='03JAN2021'd and closingdate&amp;lt;='07FEB2023'd) OR (opendate&amp;gt;='03JAN202'd and closingdate is null)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but even this logic fails because a closing date of '02JAN2021'd would pass.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please take some time and carefully and thoroughly write out the proper IF statements that will work for you (you can do this in plain English, the IF statements don't have to be in SAS).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 18:03:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857613#M338870</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-07T18:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Why is it not returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857614#M338871</link>
      <description>&lt;P&gt;So something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   (open between &amp;amp;date1 and &amp;amp;date2) 
or (close between &amp;amp;date1 and &amp;amp;date2)
or (missing(close) and open &amp;gt; &amp;amp;date3)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Feb 2023 17:33:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857614#M338871</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-07T17:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Why is it not returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857617#M338873</link>
      <description>&lt;P&gt;So before you said:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where
sourcecode in ('125', '154', '264') and opendate &amp;gt;= ‘2021-03-01’ and closingdate &amp;lt;= ‘2023-02-07’  /* and closingdate is null */ &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are doing this in SAS then the syntax would be more like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where sourcecode in ('125', '154', '264')
  and opendate &amp;gt;=  '01MAR2021'd
  and closingdate &amp;lt;= '07FEB2023'd
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since SAS treats missing values as less than any valid number then "null" values of CLOSINGDATE would be included in that last AND.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If for some reason you had to push that logic into some external database that uses TRI level logic instead of normal BINARY logic you could add that extra condition this way.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where sourcecode in ('125', '154', '264')
  and opendate &amp;gt;=  '01MAR2021'd
  and (closingdate &amp;lt;= '07FEB2023'd or closingdate is null)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Feb 2023 17:46:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-it-not-returning-null-values/m-p/857617#M338873</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-07T17:46:21Z</dc:date>
    </item>
  </channel>
</rss>

