<?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: BETWEEN-AND in logical expressions: WHERE, IF-THEN and SELECT-WHEN in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403054#M97919</link>
    <description>&lt;P&gt;The between-and operator works only in a "where-expression", the use of which is limited to the where statement in data steps, the where= dataset option, and the where clause in proc sql.&lt;/P&gt;
&lt;P&gt;See (for instance) &lt;A href="https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a001116114.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a001116114.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The where startement as part of the select-block is different from the where statement used to limit observations being read, and only supports syntax allowed in standard conditions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IMHO, the between-and syntax is a leftover from COBOL-influenced times. If I were SAS, I'd have dropped it long ago in favor of "x &amp;lt; value &amp;lt; y", or even stayed only with the "x &amp;lt; value and value &amp;lt; y" used in all other languages.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Oct 2017 08:08:18 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-10-11T08:08:18Z</dc:date>
    <item>
      <title>BETWEEN-AND in logical expressions: WHERE, IF-THEN and SELECT-WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403045#M97917</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;QUESTION&lt;/STRONG&gt;: Is there any systemic reason in the SAS Base 9.4 programming model, why the logical expression&amp;nbsp;&lt;STRONG&gt;BETWEEN-AND&lt;/STRONG&gt;&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;&lt;U&gt;cannot be used&lt;/U&gt; &lt;/STRONG&gt;&lt;/FONT&gt;in &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;IF-THEN&lt;/STRONG&gt;&lt;/FONT&gt; and in &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;SELECT-WHEN&lt;/STRONG&gt;&lt;/FONT&gt; statements?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;BETWEEN-AND&lt;/STRONG&gt; seem to be &lt;FONT color="#008000"&gt;&lt;U&gt;working only&lt;/U&gt;&lt;/FONT&gt; in &lt;FONT color="#008000"&gt;&lt;STRONG&gt;WHERE&lt;/STRONG&gt;&lt;/FONT&gt; statements and when used in&amp;nbsp;&lt;STRONG&gt;IF-THEN&lt;/STRONG&gt; or &lt;STRONG&gt;SELECT-WHEN&lt;/STRONG&gt; there are &lt;STRONG&gt;errors&lt;/STRONG&gt; reported. Does it mean that BETWEEN-AND expression&amp;nbsp;has some kind of a special status within SAS Base 9.4?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First we&amp;nbsp;create a sample data set WORK.test where we have only one numeric variable (column) Order_ID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data WORK.test;
   INFILE DATALINES;
   INPUT Order_ID : 12.;
DATALINES;
1
2
3
4
5
6
7
8
9
10
;;;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then we&amp;nbsp;would like to output to a new data set work.test2 only observations which have value ORDER_ID between 5 and 7.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We can approach&amp;nbsp;this in two ways:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Scenario #1: &lt;STRONG&gt;filter input&lt;/STRONG&gt; data using &lt;U&gt;WHERE&lt;/U&gt; clause&lt;/LI&gt;&lt;LI&gt;Scenario #2:&amp;nbsp;&lt;STRONG&gt;control output&lt;/STRONG&gt; using either &lt;U&gt;IF-THEN&lt;/U&gt; statement or &lt;U&gt;SELECT-WHEN&lt;/U&gt; statement&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Let's start with Scenario #1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using &lt;STRONG&gt;5 &amp;lt;= Order_ID &amp;lt;=7&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA work.test2;
	SET work.test;
        WHERE (&lt;STRONG&gt;5 &amp;lt;= Order_ID &amp;lt;= 7&lt;/STRONG&gt;);
RUN;&lt;/PRE&gt;&lt;P&gt;or using &lt;STRONG&gt;Order_ID BETWEEN 5 AND 7&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA work.test2;
	SET work.test;
        WHERE (&lt;STRONG&gt;Order_ID BETWEEN 5 AND 7&lt;/STRONG&gt;);
RUN;&lt;/PRE&gt;&lt;P&gt;generates exactly the same result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="scenario-1.png" style="width: 92px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15770i3EA4664094AC5025/image-size/large?v=v2&amp;amp;px=999" role="button" title="scenario-1.png" alt="scenario-1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when we follow the Scenario #2 (controlling the output with IF-THEN or with SELECT-WHEN), we will get the following results:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA work.test2;
	SET work.test;
        &lt;STRONG&gt;IF&lt;/STRONG&gt; (&lt;STRONG&gt;5 &amp;lt;= Order_ID &amp;lt;= 7&lt;/STRONG&gt;) &lt;STRONG&gt;THEN&lt;/STRONG&gt; OUTPUT;
RUN;&lt;/PRE&gt;&lt;P&gt;and&lt;/P&gt;&lt;PRE&gt;DATA work.test2;
    SET work.test;
    &lt;STRONG&gt;SELECT&lt;/STRONG&gt;; &lt;BR /&gt;      &lt;STRONG&gt;WHEN&lt;/STRONG&gt; (&lt;STRONG&gt;5 &amp;lt;= Order_ID &amp;lt;= 7&lt;/STRONG&gt;) OUTPUT;&lt;BR /&gt;      &lt;STRONG&gt;OTHERWISE&lt;/STRONG&gt;;&lt;BR /&gt;    &lt;STRONG&gt;END&lt;/STRONG&gt;;&lt;BR /&gt;RUN;&lt;/PRE&gt;&lt;P&gt;both generate the expected&amp;nbsp;data set:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="scenario-1.png" style="width: 92px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15770i3EA4664094AC5025/image-size/large?v=v2&amp;amp;px=999" role="button" title="scenario-1.png" alt="scenario-1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but using the logical expression BETWEEN-AND will generate errors when used in &lt;STRONG&gt;IF-THEN&lt;/STRONG&gt; and in &lt;STRONG&gt;SELECT-WHEN&lt;/STRONG&gt; statements:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA work.test2;
    SET work.test;
    &lt;STRONG&gt;IF&lt;/STRONG&gt; (&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Order_ID BETWEEN 5 AND 7&lt;/STRONG&gt;&lt;/FONT&gt;) &lt;STRONG&gt;THEN&lt;/STRONG&gt; OUTPUT;
RUN;&lt;/PRE&gt;&lt;DIV class="sasError"&gt;we get error messages:&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&lt;FONT color="#FF0000"&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&lt;FONT color="#FF0000"&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/FONT&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA work.test2;
    SET work.test;
    &lt;STRONG&gt;SELECT&lt;/STRONG&gt;; &lt;BR /&gt;      &lt;STRONG&gt;WHEN&lt;/STRONG&gt; (&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Order_ID BETWEEN 5 AND 7&lt;/STRONG&gt;&lt;/FONT&gt;) OUTPUT;&lt;BR /&gt;      &lt;STRONG&gt;OTHERWISE&lt;/STRONG&gt;;&lt;BR /&gt;    &lt;STRONG&gt;END&lt;/STRONG&gt;;&lt;BR /&gt;RUN;&lt;/PRE&gt;&lt;P&gt;we get error messages:&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasError"&gt;&lt;FONT color="#FF0000"&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&lt;FONT color="#FF0000"&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/FONT&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above examples have been tested in SAS Studio 9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking forward to feedback from more experienced SAS Programmers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it a feature or a bug? &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 07:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403045#M97917</guid>
      <dc:creator>wYrazik</dc:creator>
      <dc:date>2017-10-11T07:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: BETWEEN-AND in logical expressions: WHERE, IF-THEN and SELECT-WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403053#M97918</link>
      <description>&lt;P&gt;I know, reading documentation is boring, but often enlightening. The bad news: you haven't discovered a bug. Between can't be used in if-statements.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 08:08:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403053#M97918</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-10-11T08:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: BETWEEN-AND in logical expressions: WHERE, IF-THEN and SELECT-WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403054#M97919</link>
      <description>&lt;P&gt;The between-and operator works only in a "where-expression", the use of which is limited to the where statement in data steps, the where= dataset option, and the where clause in proc sql.&lt;/P&gt;
&lt;P&gt;See (for instance) &lt;A href="https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a001116114.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a001116114.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The where startement as part of the select-block is different from the where statement used to limit observations being read, and only supports syntax allowed in standard conditions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IMHO, the between-and syntax is a leftover from COBOL-influenced times. If I were SAS, I'd have dropped it long ago in favor of "x &amp;lt; value &amp;lt; y", or even stayed only with the "x &amp;lt; value and value &amp;lt; y" used in all other languages.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 08:08:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403054#M97919</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-11T08:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: BETWEEN-AND in logical expressions: WHERE, IF-THEN and SELECT-WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403067#M97924</link>
      <description>&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;Thank You for your response as a more experience SAS programmer.. I&amp;nbsp;truly appreciate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm sorry that I didn't include information that I read the manuals. As a new user of SAS 9.4, I first had read several documents before preparing an example and posting my question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In particular I went through:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Step-by-Step Programming with Base SAS 9.4&lt;/LI&gt;&lt;LI&gt;SAS 9.4 DATA Step Statements: Reference&lt;/LI&gt;&lt;LI&gt;SAS 9.4 Language Reference: Concepts&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;There is no specific information in [1].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In [2] there is a &lt;A href="http://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n1xbr9r0s9veq0n137iftzxq4g7e.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p1hey6ghqb6jmtn13xhsdm1v9he8" target="_blank"&gt;section&lt;/A&gt; "WHERE Expression Only" with BETWEEN-AND operator.&amp;nbsp;But there is no explanation why a logical expression with BETWEEN-AND operator as such can be only used in WHERE statements and not in IF-THEN or SELECT-WHEN. It is something unusual in programming languages.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In [3] there is a &lt;A href="http://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=p04fy20d8il3nfn1ssywe4f25k27.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;section&lt;/A&gt; "Deciding Whether to Use a WHERE Expression or a Subsetting IF Statement", but there is still no explanation why this particular operator expression cannot be used in in IF-THEN and SELECT-WHEN statements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For me it was quite strange that there are two types of operators, ones that can be used everywhere and there are specific operators:&lt;BR /&gt;BETWEEN-AND, CONTAINS, IS MISSING or IS NULL, LIKE, SAME-AND, and Sounds-Like&lt;BR /&gt;which can be only used in the WHERE statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is why, I asked my question and prepared my detailed example.&amp;nbsp;I'm sorry if I made an impression that I didn't RTFM &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once again, Thank You for Your comment.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 09:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403067#M97924</guid>
      <dc:creator>wYrazik</dc:creator>
      <dc:date>2017-10-11T09:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: BETWEEN-AND in logical expressions: WHERE, IF-THEN and SELECT-WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403068#M97925</link>
      <description>&lt;P&gt;Thank You for providing a detailed answer and confirmation that&amp;nbsp;BETWEEN-AND and also other operators: CONTAINS, IS MISSING or IS NULL, LIKE, SAME-AND, and Sounds-Like&amp;nbsp; can only be used in WHERE statements.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am still wondering, why such a strange dichotomy between operators was introduced into the SAS Base Language. That is why, I asked the question with a smile: is it a feature or a bug? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You again for your detailed answer and providing the link - it is always very helpful.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 09:19:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403068#M97925</guid>
      <dc:creator>wYrazik</dc:creator>
      <dc:date>2017-10-11T09:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: BETWEEN-AND in logical expressions: WHERE, IF-THEN and SELECT-WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403071#M97928</link>
      <description>&lt;P&gt;Thinking through it again, I came to the conclusion that the between-and exists because it is part of ANSI SQL, and SAS decided to make all where-statements (SQL and elsewhere) to use that as standard. It's therefore only available when applied to subsetting datasets on input, but not in any other conditions. See it as part of the read mechanism, but not of programming logic.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 09:27:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403071#M97928</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-11T09:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: BETWEEN-AND in logical expressions: WHERE, IF-THEN and SELECT-WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403083#M97935</link>
      <description>&lt;P&gt;At this stage, I know, BETWEEN-AND can only be used in WHERE statements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After Your indication of SQL, I have just investigated&amp;nbsp;the&amp;nbsp;subject further.&amp;nbsp;There is a chapter &lt;STRONG&gt;&lt;A href="http://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetVersion=9.4&amp;amp;docsetTarget=n06cy7dznbx6gen1q9mat8de6rdq.htm&amp;amp;locale=en" target="_self"&gt;Understanding SAS Indexes&lt;/A&gt;&amp;nbsp;&lt;/STRONG&gt;in SAS 9.4 Language Reference: Concepts, Sixth Edition. It&amp;nbsp;provides detailed explanation about indexing of data by SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It can&amp;nbsp;be possible that specific operators i.e.&amp;nbsp;BETWEEN-AND, CONTAINS, IS MISSING or IS NULL, LIKE, SAME-AND, and Sounds-Like are&amp;nbsp;only allowed in the WHERE statement, so &lt;U&gt;the User is somehow forced to use them at the stage of filtering the input&lt;/U&gt; before the data is delivered into the PDV (Program Data Vector) for further processing in a cursor-like fashion (in a loop).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In case of operators which are applied to strings (text): CONTAINS, LIKE, Sound-Like the performance gain is quite obvious. But in case of BETWEEN-AND it is not so obvious. For instance: is it always better to use (&lt;SPAN&gt;x BETWEEN a AND b) over (a&amp;lt;=x&amp;lt;=b) expressions in the WHERE statements?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe I will learn something more in the future.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 10:03:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403083#M97935</guid>
      <dc:creator>wYrazik</dc:creator>
      <dc:date>2017-10-11T10:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: BETWEEN-AND in logical expressions: WHERE, IF-THEN and SELECT-WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403192#M97965</link>
      <description>&lt;P&gt;Some of those tasks are available using other functions. SAS data step code existed before the incorporation of Proc SQL to SAS I believe.&lt;/P&gt;
&lt;P&gt;All of those statements you mention appear to come from the SQL world and the uses are defined there. SAS has maintained the same limits. I think it makes sense that you don't want to use a code element from something like SQL that behaves differently as much as practical so you don't have to switch as many gears when going from data step to Proc SQL and back.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of "is missing" use Missing(expression). "Is null" is equivalent to missing as far as SAS is concerned.&lt;/P&gt;
&lt;P&gt;I have no idea what a "Same And"&amp;nbsp;code element may be so I can't provide an example.&lt;/P&gt;
&lt;P&gt;The function Soundex is used to encode strings to match for sounds similar searching. Note that the documentation for the WHERE expression says:&lt;/P&gt;
&lt;PRE&gt;The sounds-like ( =*) operator selects observations that contain a spelling variation of a specified word or words. The operator uses the Soundex algorithm to compare the variable value and the operand. For more information, see the SOUNDEX function in SAS Functions and CALL Routines: Reference. 

Note: Note that the SOUNDEX algorithm is English-biased, and is less useful for languages other than English. &lt;/PRE&gt;
&lt;P&gt;These other functions are usable in any comparison or calculation you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are attempting to transfer existing knowledge of SQL (of some flavor) to data step programming then you want to look at references for data step&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 14:48:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403192#M97965</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-11T14:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: BETWEEN-AND in logical expressions: WHERE, IF-THEN and SELECT-WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403259#M97984</link>
      <description>Hi:&lt;BR /&gt;  My .02 ...&lt;BR /&gt;&lt;BR /&gt;  The DATA step processing and IF logic and IF operators existed long before SAS implemented SQL capability. And, yes, those features of SQL that are allowed in WHERE were implemented in PROC SQL when it was introduced.&lt;BR /&gt;&lt;BR /&gt;  There are some Tech Support notes that discuss how you would achieve the equivalent of LIKE or CONTAINS, for example, in DATA step: &lt;A href="http://support.sas.com/kb/43/303.html" target="_blank"&gt;http://support.sas.com/kb/43/303.html&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;  However, I learned =: and INDEX before I learned  CONTAINS, so I never thought it was a bug when WHERE operators only worked in WHERE statements and clauses.&lt;BR /&gt;&lt;BR /&gt;You will find the documentation for the WHERE statement operators here:&lt;BR /&gt;&lt;A href="http://go.documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n1xbr9r0s9veq0n137iftzxq4g7e.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n0zefy6heu3ai3n1pfwmi2330f85" target="_blank"&gt;http://go.documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n1xbr9r0s9veq0n137iftzxq4g7e.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n0zefy6heu3ai3n1pfwmi2330f85&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;You will find the documentation for the operators you can use in SAS expressions here: &lt;A href="http://go.documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=p00iah2thp63bmn1lt20esag14lh.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://go.documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=p00iah2thp63bmn1lt20esag14lh.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt; (look at the comparison operators).&lt;BR /&gt;&lt;BR /&gt;Programming 1 is a free elearning class and it will outline both the use of WHERE and the use of IF and discuss the operators available. You can activate Programming 1 by clicking on the link at the top of this page: &lt;A href="https://support.sas.com/edu/elearning.html?ctry=us&amp;amp;productType=library" target="_blank"&gt;https://support.sas.com/edu/elearning.html?ctry=us&amp;amp;productType=library&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;Cynthia&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Oct 2017 17:04:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403259#M97984</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-10-11T17:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: BETWEEN-AND in logical expressions: WHERE, IF-THEN and SELECT-WHEN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403267#M97988</link>
      <description>&lt;P&gt;It is not a feature or a bug. It was a design decision. The BETWEEN and other SQL syntax features are supported by the WHERE statement, but not in other normal SAS statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect that it was done as part of supporting external databases with libname engines. So as part of pushing WHERE clauses into the external database they decided to except the SQL like syntax so that it would be easier for SAS to push more WHERE conditions down without having to re-write them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But modifying how all of the SAS statements work would have been a much large task and probably would have had the potential for breaking customer's existing code bases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that they are also many SAS features like the : modifier on comparison operators or variables lists that are not supported by PROC SQL.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 17:37:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BETWEEN-AND-in-logical-expressions-WHERE-IF-THEN-and-SELECT-WHEN/m-p/403267#M97988</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-11T17:37:16Z</dc:date>
    </item>
  </channel>
</rss>

