<?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: How are #1: X in(10-12) and #2: 10&amp;lt;=X=12 different? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-are-1-X-in-10-12-and-2-10-lt-X-12-different/m-p/450110#M113328</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I was just pointing out to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/191587"&gt;@jaeahn&lt;/a&gt; that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1- The answer to his question was in the sas log -where one should always look first- since the code&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;X in (10-12) &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;shows in the log as&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;X in (-12,10) &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2- There can be surprises for some syntaxes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think this is do do with poor implementation of the in() clause (though when there are few values -like here- a list could be created to speed things up).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rather, WHERE clauses always execute SAS functions slower than IF statements.&lt;/P&gt;
&lt;P&gt;As soon as a function is introduced (even without the user explicitly doing so, such as here), IF statements are faster.&lt;/P&gt;
&lt;P&gt;When only in/equalities are used, IF statements are slower.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something to do with functions accessing data faster from the PDV than from the read buffer I suppose, though I was never given a clear explanation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's all I was trying to point out. Sorry about the confusion. My reply should have been to the OP.&lt;/P&gt;</description>
    <pubDate>Sat, 31 Mar 2018 08:04:30 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2018-03-31T08:04:30Z</dc:date>
    <item>
      <title>How are #1: X in(10-12) and #2: 10&lt;=X=12 different?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-are-1-X-in-10-12-and-2-10-lt-X-12-different/m-p/450062#M113320</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The two codes below subsets data differently, but I'm not sure why.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;code #1&lt;/P&gt;&lt;P&gt;if not (10&amp;lt;=X&amp;lt;=12 &amp;amp; Y&amp;gt;=50) then&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; ----;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;code #2&lt;/P&gt;&lt;P&gt;if not (X in (10-12) &amp;amp; Y&amp;gt;=50) then&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; ----;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't understand why 10&amp;lt;=X&amp;lt;=12 is performing differently from X in(10-12).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jae&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Mar 2018 20:39:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-are-1-X-in-10-12-and-2-10-lt-X-12-different/m-p/450062#M113320</guid>
      <dc:creator>jaeahn</dc:creator>
      <dc:date>2018-03-30T20:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: How are #1: X in(10-12) and #2: 10&lt;=X=12 different?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-are-1-X-in-10-12-and-2-10-lt-X-12-different/m-p/450073#M113321</link>
      <description>&lt;P&gt;Please run this code and look at the results.&lt;/P&gt;
&lt;PRE&gt;data _null_;
   input x;
   file print;
   If x in (10-12) then put x= +1 "is in (10-12)";
   If x in (10 11 12) then put x= +1 "is in (10 11 12)";
   If x in (10:12) then put x= +1 "is in (10:12)";
   If 10 le x le 12 then put x= +1 "is in 10 le x le 12";
datalines;
1
1.5
2
3
4
10
10.1
11
-12
11.7
12
;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IN is used for a LIST of values so the main difference is the treatment of decimal values. A second consideration is that for numeric values to provide a list of sequential integer values the syntax is (10:12). When you use (10-12) SAS examines the values and treats the - as part of the 12 or a negative 12 in the list.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Mar 2018 21:25:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-are-1-X-in-10-12-and-2-10-lt-X-12-different/m-p/450073#M113321</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-30T21:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: How are #1: X in(10-12) and #2: 10&lt;=X=12 different?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-are-1-X-in-10-12-and-2-10-lt-X-12-different/m-p/450084#M113322</link>
      <description>&lt;P&gt;I think that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;already answered your question, but here is another way to look at it. I was surprised to find that in (10-12) is treated as two numbers:&lt;/P&gt;
&lt;PRE&gt;data have;
   input x;
datalines;
1
1.5
2
3
4
-2
10
10.1
11
-12
11.7
12
;
run;
data incomma;
  set have (where=(x in (10,12)));
run;
data indash;
  set have (where=(x in (10-12)));
run;
data indashPLUS;
  set have (where=(x in (10-12,12)));
run;
data between;
  set have (where=(x between 10 and 12));
run;
data ltetc;
  set have (where=(10 le x le 12));
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Mar 2018 23:55:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-are-1-X-in-10-12-and-2-10-lt-X-12-different/m-p/450084#M113322</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-03-30T23:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: How are #1: X in(10-12) and #2: 10&lt;=X=12 different?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-are-1-X-in-10-12-and-2-10-lt-X-12-different/m-p/450100#M113325</link>
      <description>And just for fun, try X in (10:12) and X in (10--12)</description>
      <pubDate>Sat, 31 Mar 2018 01:51:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-are-1-X-in-10-12-and-2-10-lt-X-12-different/m-p/450100#M113325</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-31T01:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: How are #1: X in(10-12) and #2: 10&lt;=X=12 different?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-are-1-X-in-10-12-and-2-10-lt-X-12-different/m-p/450102#M113326</link>
      <description>&lt;P&gt;Note that the answer to your question is in the SAS log, as the created code is explicited there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note the code in the log (and cry when you look at the elapse time) when using&lt;/P&gt;
&lt;P class="western" style="margin-bottom: 0cm; line-height: 100%;" lang="en-US"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT face="Courier New, monospace"&gt;&lt;FONT style="font-size: 10pt;" size="2"&gt;&lt;SPAN&gt;&lt;SPAN style="background: #ffffff;"&gt;where&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Courier New, monospace"&gt;&lt;FONT style="font-size: 10pt;" size="2"&gt;&lt;SPAN&gt;&lt;SPAN style="background: #ffffff;"&gt; X in (&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080"&gt;&lt;FONT face="Courier New, monospace"&gt;&lt;FONT style="font-size: 10pt;" size="2"&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: #ffffff;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Courier New, monospace"&gt;&lt;FONT style="font-size: 10pt;" size="2"&gt;&lt;SPAN&gt;&lt;SPAN style="background: #ffffff;"&gt;:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080"&gt;&lt;FONT face="Courier New, monospace"&gt;&lt;FONT style="font-size: 10pt;" size="2"&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: #ffffff;"&gt;4&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Courier New, monospace"&gt;&lt;FONT style="font-size: 10pt;" size="2"&gt;&lt;SPAN&gt;&lt;SPAN style="background: #ffffff;"&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;versus&lt;/P&gt;
&lt;P class="western" style="margin-bottom: 0cm; line-height: 100%;" lang="en-US"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT face="Courier New, monospace"&gt;&lt;FONT style="font-size: 10pt;" size="2"&gt;&lt;SPAN&gt;&lt;SPAN style="background: #ffffff;"&gt;if&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Courier New, monospace"&gt;&lt;FONT style="font-size: 10pt;" size="2"&gt;&lt;SPAN&gt;&lt;SPAN style="background: #ffffff;"&gt; X in (&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080"&gt;&lt;FONT face="Courier New, monospace"&gt;&lt;FONT style="font-size: 10pt;" size="2"&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: #ffffff;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Courier New, monospace"&gt;&lt;FONT style="font-size: 10pt;" size="2"&gt;&lt;SPAN&gt;&lt;SPAN style="background: #ffffff;"&gt;:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080"&gt;&lt;FONT face="Courier New, monospace"&gt;&lt;FONT style="font-size: 10pt;" size="2"&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: #ffffff;"&gt;4&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Courier New, monospace"&gt;&lt;FONT style="font-size: 10pt;" size="2"&gt;&lt;SPAN&gt;&lt;SPAN style="background: #ffffff;"&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="western" style="margin-bottom: 0cm; line-height: 100%;" lang="en-US"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first one generates :&lt;/P&gt;
&lt;P style="margin-bottom: 0cm; border: 1px solid #000000; padding: 0.04cm 0.14cm; line-height: 100%;" lang="en-GB"&gt;&lt;FONT face="SAS Monospace, monospace"&gt;&lt;FONT style="font-size: 8pt;" size="1"&gt;WHERE &lt;STRONG&gt;&lt;FONT color="#FF6600"&gt;(X=INT(X)) &lt;/FONT&gt;&lt;/STRONG&gt;and (X&amp;gt;=1 and X&amp;lt;=4);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;and runs much slower&lt;FONT color="#000000"&gt;&lt;FONT size="2"&gt;&lt;FONT face="Courier New, monospace"&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 31 Mar 2018 02:53:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-are-1-X-in-10-12-and-2-10-lt-X-12-different/m-p/450102#M113326</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-03-31T02:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: How are #1: X in(10-12) and #2: 10&lt;=X=12 different?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-are-1-X-in-10-12-and-2-10-lt-X-12-different/m-p/450104#M113327</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;: If you're pointing out that the use of the in operator in a where statement was poorly implemented (as compared with its implementation in an if statement), I agree.&amp;nbsp;Both the where option and the where statement&amp;nbsp;run between 2 and 3 times slower than using an if statement. Rick Langston pointed that out, years ago, in a SUGI paper (see:&amp;nbsp;&lt;SPAN&gt;www2.sas.com/proceedings/sugi30/002-30.pdf ).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, both the do the same thing and the point of my post was simply to show&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/191587"&gt;@jaeahn&lt;/a&gt;&amp;nbsp;some additional examples of how the in operator works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 31 Mar 2018 03:40:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-are-1-X-in-10-12-and-2-10-lt-X-12-different/m-p/450104#M113327</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-03-31T03:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: How are #1: X in(10-12) and #2: 10&lt;=X=12 different?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-are-1-X-in-10-12-and-2-10-lt-X-12-different/m-p/450110#M113328</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I was just pointing out to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/191587"&gt;@jaeahn&lt;/a&gt; that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1- The answer to his question was in the sas log -where one should always look first- since the code&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;X in (10-12) &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;shows in the log as&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;X in (-12,10) &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2- There can be surprises for some syntaxes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think this is do do with poor implementation of the in() clause (though when there are few values -like here- a list could be created to speed things up).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rather, WHERE clauses always execute SAS functions slower than IF statements.&lt;/P&gt;
&lt;P&gt;As soon as a function is introduced (even without the user explicitly doing so, such as here), IF statements are faster.&lt;/P&gt;
&lt;P&gt;When only in/equalities are used, IF statements are slower.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something to do with functions accessing data faster from the PDV than from the read buffer I suppose, though I was never given a clear explanation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's all I was trying to point out. Sorry about the confusion. My reply should have been to the OP.&lt;/P&gt;</description>
      <pubDate>Sat, 31 Mar 2018 08:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-are-1-X-in-10-12-and-2-10-lt-X-12-different/m-p/450110#M113328</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-03-31T08:04:30Z</dc:date>
    </item>
  </channel>
</rss>

