<?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: Curious about FINDW / INDEXW results in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477825#M123134</link>
    <description>&lt;P&gt;Hi ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the replies so far ... for your information, I have&amp;nbsp;now reported this to SAS Technical Support. In the ticket I have also notified them of this thread, so that they can gain any insight from the Users here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks all &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;Antony&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Jul 2018 10:43:16 GMT</pubDate>
    <dc:creator>aknight1</dc:creator>
    <dc:date>2018-07-13T10:43:16Z</dc:date>
    <item>
      <title>Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477803#M123128</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While testing a macro to return email addresses from a metadata dataset, I get (seemingly) inconsistent results from the FINDW and INDEXW functions.&amp;nbsp;When running the code given below, I am really curious why the datasets A1 and A2 are returning different results, and why the datasets B1 and B2 are returning different results.&amp;nbsp;It seems like the order in which I check things influences the result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My feeling is that A1 and A2 should be same, and that B1 and B2 should be&amp;nbsp;same. Can anybody give me a hint why they are not?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get:&lt;/P&gt;&lt;P&gt;NOTE: Table WORK.TEST_A1 created, with 1 rows and 2 columns.&lt;/P&gt;&lt;P&gt;NOTE: Table WORK.TEST_A2 created, with 0 rows and 2 columns.&lt;/P&gt;&lt;P&gt;NOTE: Table WORK.TEST_B1 created, with 0 rows and 2 columns.&lt;/P&gt;&lt;P&gt;NOTE: Table WORK.TEST_B2 created, with 1 rows and 2 columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running in SAS EG 7.1 on UNIX, and in SAS 9.4 on WINDOWS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data T_USER_EMAIL;
   length userid $6 email $100;
   userid='ABC090'; email='john.smith@xyz.com';    output;
   userid='DEF090'; email='joanna.smythe@xyz.com'; output;
   userid='HIJ090'; email=' ';                     output;
run;

* test with Name;
proc sql noprint;
   create table test_A1 as
   select *
     from T_USER_EMAIL
    where index(upcase(email),'@XYZ.COM')
      and ( (FINDW(" JOHN.SMITH xxx",strip(upcase(scan(email,1,'@'))),' ')) or
            (FINDW(" JOHN.SMITH xxx",strip(upcase(userid)))) ) ;
quit;

proc sql noprint;
   create table test_A2 as
   select *
     from T_USER_EMAIL
    where index(upcase(email),'@XYZ.COM')
      and ( (FINDW(" JOHN.SMITH xxx",strip(upcase(userid)))) or 
            (FINDW(" JOHN.SMITH xxx",strip(upcase(scan(email,1,'@'))),' ')) ) ;
quit;


* test with UserId;
proc sql noprint;
   create table test_B1 as
   select *
     from T_USER_EMAIL
    where index(upcase(email),'@XYZ.COM')
      and ( (FINDW(" DEF090 xxx",strip(upcase(scan(email,1,'@'))),' ')) or
            (FINDW(" DEF090 xxx",strip(upcase(userid)))) ) ;
quit;

proc sql noprint;
   create table test_B2 as
   select *
     from T_USER_EMAIL
    where index(upcase(email),'@XYZ.COM')
      and ( (FINDW(" DEF090 xxx",strip(upcase(userid)))) or 
            (FINDW(" DEF090 xxx",strip(upcase(scan(email,1,'@'))),' ')) ) ;
quit;&lt;/CODE&gt;&lt;/PRE&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;(Just fyi,&amp;nbsp;I want Users to be able to provide UserIds and/or Names to the macro ... that is why the code generated by the macro is checking in both the userid and email&amp;nbsp;columns)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 07:57:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477803#M123128</guid>
      <dc:creator>aknight1</dc:creator>
      <dc:date>2018-07-13T07:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477809#M123130</link>
      <description>&lt;P&gt;I think you're on to something here. Since the condition works when the first part of the "or" returns a non-zero value, but fails when that is zero, I have a suspicion that the condition optimizer does not honor the brackets as it should and breaks off too early.&lt;/P&gt;
&lt;P&gt;Clearly a case for SAS TS, IMO.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 08:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477809#M123130</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-13T08:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477818#M123131</link>
      <description>&lt;P&gt;I agree, this seems strange. And seems to limit itself to the WHERE Clause. The two data sets created with the following code are identical&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data T_USER_EMAIL;
   length userid $6 email $100;
   userid='ABC090'; email='john.smith@xyz.com';    output;
   userid='DEF090'; email='joanna.smythe@xyz.com'; output;
   userid='HIJ090'; email=' ';                     output;
run;

* test with Name;
proc sql noprint;
   create table test_A1 as
   select *
         ,(index(upcase(email),'@XYZ.COM')
      and ( (FINDW(" JOHN.SMITH xxx",strip(upcase(scan(email,1,'@'))),' ')) or
            (FINDW(" JOHN.SMITH xxx",strip(upcase(userid)))) )) as testvar
     from T_USER_EMAIL;
quit;

proc sql noprint;
   create table test_A2 as
   select *
         ,(index(upcase(email),'@XYZ.COM')
      and ( (FINDW(" JOHN.SMITH xxx",strip(upcase(userid)))) or 
            (FINDW(" JOHN.SMITH xxx",strip(upcase(scan(email,1,'@'))),' ')) )) as testvar
     from T_USER_EMAIL;
quit;

proc compare base=test_A1 compare=test_A2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Jul 2018 09:39:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477818#M123131</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-07-13T09:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477823#M123133</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/153219"&gt;@aknight1&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I fully agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;and strongly suspect a SAS bug, a pretty substantial one indeed, which should be reported to Technical Support. Here&amp;nbsp;is a&amp;nbsp;boiled down example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
c=' ';
d='x';
run;

data want;
set have;
where find('x',c) or find('x',d);
run;

data want;
set have;
where find('y',c) or find('x',d);
run;

data want;
set have;
where find('x',c) | find(lowcase(left(' X')),d);
run;

data want;
set have;
where find('x',c) | find('x',d) | length(d)=2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log (from SAS 9.4 TS1M2 on the X64_7PRO platform):&lt;/P&gt;
&lt;PRE&gt;1    data have;
2    c=' ';
3    d='x';
4    run;

NOTE: The data set WORK.HAVE has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


5
6    data want;
7    set have;
8    where find('x',c) or find('x',d);
9    run;

NOTE: There were 0 observations read from the data set WORK.HAVE.
      WHERE not (not FIND('x', c));
NOTE: The data set WORK.WANT has 0 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


10
11   data want;
12   set have;
13   where find('y',c) or find('x',d);
14   run;

NOTE: There were 1 observations read from the data set WORK.HAVE.
      WHERE FIND('y', c) or FIND('x', d);
NOTE: The data set WORK.WANT has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


15
16   data want;
17   set have;
18   where find('x',c) | find(lowcase(left(' X')),d);
19   run;

NOTE: There were 0 observations read from the data set WORK.HAVE.
      WHERE not (not FIND('x', c));
NOTE: The data set WORK.WANT has 0 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


20
21   data want;
22   set have;
23   where find('x',c) | find('x',d) | length(d)=2;
24   run;

NOTE: There were 0 observations read from the data set WORK.HAVE.
      WHERE FIND('x', c) or (LENGTH(d)=2);
NOTE: The data set WORK.WANT has 0 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds&lt;/PRE&gt;
&lt;P&gt;Obviously, dataset WANT should contain 1 observation in all four cases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Preliminary conclusions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The bug is not limited to FINDW and INDEXW.&lt;/LI&gt;
&lt;LI&gt;It seems unrelated to PROC SQL.&lt;/LI&gt;
&lt;LI&gt;The WHERE condition, as shown in the NOTEs, is inappropriately modified ("optimized"?).&lt;/LI&gt;
&lt;LI&gt;The same modification occurs if "or" is replaced by "and" (not shown above).&lt;/LI&gt;
&lt;LI&gt;Different types of&amp;nbsp;incorrect modifications can&amp;nbsp;take place (see first vs. last example).&lt;/LI&gt;
&lt;LI&gt;The bug seems to occur as soon as the first arguments of the function calls (with the same function) result in the same string.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 10:29:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477823#M123133</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-07-13T10:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477825#M123134</link>
      <description>&lt;P&gt;Hi ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the replies so far ... for your information, I have&amp;nbsp;now reported this to SAS Technical Support. In the ticket I have also notified them of this thread, so that they can gain any insight from the Users here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks all &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;Antony&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 10:43:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477825#M123134</guid>
      <dc:creator>aknight1</dc:creator>
      <dc:date>2018-07-13T10:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477829#M123135</link>
      <description>&lt;P&gt;Ouch. This goes deeper than I initially suspected, and can turn out to be the first really SERIOUS bug I've seen with respect to SAS. It's much more serious insofar as it can go undetected for quite some time and produce false results. Can hurt much more than a simple Segmentation Violation that causes a very noticeable crash (I've found one of those quite recently in the 9.4M5 code for SAS/SHARE, see &lt;A href="http://support.sas.com/kb/62/346.html" target="_blank"&gt;http://support.sas.com/kb/62/346.html&lt;/A&gt;).&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 11:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477829#M123135</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-13T11:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477843#M123141</link>
      <description>&lt;P&gt;Wow, this could ruin my Friday. : )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example of the bug.&amp;nbsp; The compiler seems to have munged the where clause, completely ignoring the find('x',x);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1    data have;
2    x='x' ;
3    y='y' ;
4    run;

NOTE: The data set WORK.HAVE has 1 observations and 2 variables.

5
6    *bug: returns 0 and where clause is reported in log as  ;
7    *WHERE not (not FIND('x', y));
8    *so its ignorning second part of clause ;
9    data want;
10   set have;
11   where find('x',y) or find('x',x);
12   run;

NOTE: There were 0 observations read from the data set WORK.HAVE.
      WHERE not (not FIND('x', y));
NOTE: The data set WORK.WANT has 0 observations and 2 variables.
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Changing the expression slightly makes it work:&lt;/P&gt;
&lt;PRE&gt;14   *works as expected just by adding to expression;
15   data want;
16   set have;
17   where find('x',y) or (find('x',x)=1);
18   run;

NOTE: There were 1 observations read from the data set WORK.HAVE.
      WHERE FIND('x', y) or (FIND('x', x)=1);
&lt;/PRE&gt;
&lt;P&gt;Adding a blank to the literal string makes it work&lt;/P&gt;
&lt;PRE&gt;20   *works as expected ;
21   data want;
22   set have;
23   where find('x',y) or find(' x',x);
24   run;

NOTE: There were 1 observations read from the data set WORK.HAVE.
      WHERE FIND('x', y) or FIND(' x', x);
NOTE: The data set WORK.WANT has 1 observations and 2 variables.
&lt;/PRE&gt;
&lt;P&gt;If the second half of the where clause is find('y',y) you do not get the same bug as find('x',x).&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;26   *doesnt happen with variable named y?  ;
27   data want;
28   set have;
29   where find('x',y) or find('y',y);
30   run;

NOTE: There were 1 observations read from the data set WORK.HAVE.
      WHERE FIND('x', y) or FIND('y', y);
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So it's somehow related to a pesky&amp;nbsp; 'x' being mis-compiled?&amp;nbsp; My&amp;nbsp; head is hurting...&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 12:05:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477843#M123141</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2018-07-13T12:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477853#M123147</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the second half of the where clause is find('y',y) you do not get the same bug as find('x',x).&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;26   *doesnt happen with variable named y?  ;
27   data want;
28   set have;
29   where find('x',y) or find('y',y);
30   run;

NOTE: There were 1 observations read from the data set WORK.HAVE.
      WHERE FIND('x', y) or FIND('y', y);
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So it's somehow related to a pesky&amp;nbsp; 'x' being mis-compiled?&amp;nbsp; My&amp;nbsp; head is hurting...&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't think it has to do with variable names, y is affected in the same way (using your dataset HAVE):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;88   data want;
89   set have;
90   where find('y',' ') or find('y',y);
91   run;

NOTE: There were 0 observations read from the data set WORK.HAVE.
      WHERE 0 /* an obviously FALSE WHERE clause */ ;
NOTE: The data set WORK.WANT has 0 observations and 2 variables.&lt;/PRE&gt;
&lt;P&gt;It still seems to me that the equality of the first arguments (after evaluation, if any) is necessary for the bug to occur (but not sufficient, as your example with "...=1" shows).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 12:39:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477853#M123147</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-07-13T12:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477862#M123151</link>
      <description>&lt;P&gt;So if the conditions in the WHERE statement&amp;nbsp;has multiple conditions that treat a&amp;nbsp;function call (so far FIND,INDEX,FINDW,INDEX) as a boolean result AND where the first argument in all of them is the same constant value (even if the later arguments are different) then it is being optimized incorrectly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data bad;
  set sashelp.class ;
  where index('Alice M',strip(name)) or index('Alice M',strip(sex));
run;

data good;
  set sashelp.class ;
  if index('Alice M',strip(name)) or index('Alice M',strip(sex));
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;One fix is to explicitly convert the function call into a boolean expression.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data good2;
  set sashelp.class ;
  where 0^=index('Alice M',strip(name)) or 0^=index('Alice M',strip(sex));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;UPDATE&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;The where statement works properly in SAS 9.3, but not in SAS 9.4M3 or SAS 9.4M5.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 13:54:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477862#M123151</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-13T13:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477872#M123157</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;.&amp;nbsp; I see your point.&amp;nbsp; Glad it wasn't variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree with you (and&amp;nbsp;@Tom) looks like it happens when the first argument is a literal value, and the same&amp;nbsp;same literal value is used in&amp;nbsp; multiple calls to the function, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;78   data want;
79   set have;
80   where find('FOO',x) or find('FOO',y);
81   run;

NOTE: There were 0 observations read from the data set WORK.HAVE.
      WHERE not (not FIND('FOO', x));

&lt;/PRE&gt;
&lt;P&gt;That's a scary bug.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 14:11:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477872#M123157</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2018-07-13T14:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477892#M123168</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;UPDATE&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;The where statement works properly in SAS 9.3, but not in SAS 9.4M3 or SAS 9.4M5.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is very interesting (and good news for older projects).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's another example, still following the pattern&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;has described, but now using a function that produces a character result (i.e. with non-blank values being evaluated as TRUE) and without any involvement of variables:&lt;/P&gt;
&lt;PRE&gt;105  data have;
106  run;

NOTE: The data set WORK.HAVE has 1 observations and 0 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


107
108  data want;
109  set have;
110  where cat('x','y') | cat('x');
111  run;

NOTE: There were 1 observations read from the data set WORK.HAVE.
      WHERE not (not 'xy');&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Jul 2018 14:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477892#M123168</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-07-13T14:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477895#M123170</link>
      <description>&lt;P&gt;Not going to go into more testing but you could try simplifying the FINDW code by using the I and R (or T)&amp;nbsp;options and drop the strip(upcase()) code.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 14:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477895#M123170</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-13T14:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477964#M123186</link>
      <description>&lt;P&gt;Try removing the parentheses around the two findw conditions....it seems to work for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data T_USER_EMAIL;
   length userid $6 email $100;
   userid='ABC090'; email='john.smith@xyz.com';    output;
   userid='DEF090'; email='joanna.smythe@xyz.com'; output;
   userid='HIJ090'; email=' ';                     output;
run;

* test with Name;
proc sql noprint;
   create table test_A1 as
   select *
     from T_USER_EMAIL
    where index(upcase(email),'@XYZ.COM')
      and  (FINDW(" JOHN.SMITH xxx",strip(upcase(scan(email,1,'@'))),' ')) or
            (FINDW(" JOHN.SMITH xxx",strip(upcase(userid))))  ;
quit;

proc sql noprint;
   create table test_A2 as
   select *
     from T_USER_EMAIL
    where index(upcase(email),'@XYZ.COM')
      and  (FINDW(" JOHN.SMITH xxx",strip(upcase(userid)))) or 
            (FINDW(" JOHN.SMITH xxx",strip(upcase(scan(email,1,'@'))),' '))  ;
quit;


* test with UserId;
proc sql noprint;
   create table test_B1 as
   select *
     from T_USER_EMAIL
    where index(upcase(email),'@XYZ.COM')
      and  (FINDW("DEF090 xxx",strip(upcase(scan(email,1,'@'))),' ')) or
            (FINDW("DEF090 xxx",strip(upcase(userid))))  ;
quit;

proc sql noprint;
   create table test_B2 as
   select *
     from T_USER_EMAIL
    where index(upcase(email),'@XYZ.COM')
      and  (FINDW("DEF090 xxx",strip(upcase(userid)))) or 
            (FINDW("DEF090 xxx",strip(upcase(scan(email,1,'@'))),' '))  ;
quit;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Jul 2018 17:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/477964#M123186</guid>
      <dc:creator>twildone</dc:creator>
      <dc:date>2018-07-13T17:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/489572#M127875</link>
      <description>&lt;P&gt;Hi all ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just for your information ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Today I was notified by SAS Tech Support that the Hot-Fix for this bug is now available.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Arial"&gt;&lt;SPAN style="font-size: 11pt;"&gt;Product: &lt;/SPAN&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;STRONG&gt;Base SAS 9.4_M3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;SPAN style="color: black; font-family: &amp;quot;Arial&amp;quot;,sans-serif; font-size: 11pt;"&gt;&lt;BR /&gt;&lt;SPAN&gt;Hot Fix: &lt;/SPAN&gt;&lt;STRONG&gt;V01099&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: black; font-family: &amp;quot;Arial&amp;quot;,sans-serif; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;FONT color="#000000" face="Microsoft Sans Serif" size="3"&gt;This hot fix is now available to customers on our external download site: &lt;/FONT&gt;&lt;SPAN style="color: black; font-family: &amp;quot;Arial&amp;quot;,sans-serif; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN style="font-size: 11pt;"&gt;&lt;A href="http://ftp.sas.com/techsup/download/hotfix/HF2/V01.html#V01099" target="_blank"&gt;&lt;FONT color="#0000ff" face="Microsoft Sans Serif"&gt;http://ftp.sas.com/techsup/download/hotfix/HF2/V01.html#V01099&lt;/FONT&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN style="color: black; font-family: &amp;quot;Arial&amp;quot;,sans-serif; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;V01099 is currently available on the following platform(s): &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mainframe: &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;FONT color="#008000" face="Arial"&gt;z/OS, z/OS 64-bit&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: &amp;quot;Arial&amp;quot;,sans-serif; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;SPAN&gt;PC: &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;FONT color="#008000" face="Arial"&gt;Windows, Windows for x64&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: &amp;quot;Arial&amp;quot;,sans-serif; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;SPAN&gt;UNIX: &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;FONT color="#008000" face="Arial"&gt;64-bit Enabled Solaris, 64-bit Enabled AIX, HP-UX IPF, Linux for x64, Solaris for x64&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to all&amp;nbsp;who responded to my question, and encouraged me to contact SAS Tech Support.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Special thanks to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;... your concise examples were very helpful in convincing SAS Tech Support that this is a genuine problem that needs to be fixed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Antony&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2018 13:06:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/489572#M127875</guid>
      <dc:creator>aknight1</dc:creator>
      <dc:date>2018-08-24T13:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/489643#M127899</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/153219"&gt;@aknight1&lt;/a&gt;: It's a veritable bug. This very example, &lt;EM&gt;verbatim&lt;/EM&gt;, was posted on SAS-L a month or so ago by Roger DeAngelis and discussed and taken apart ad nauseam. And I believe that as a result of the consensus it's been already reported. Which doesn't mean that it will be fixed any time soon, particularly since it's pretty subtle and materializes only under very specific conditions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2018 15:30:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/489643#M127899</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2018-08-24T15:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/489647#M127901</link>
      <description>&lt;P&gt;It &lt;EM&gt;&lt;STRONG&gt;has&lt;/STRONG&gt;&lt;/EM&gt; now been fixed. See my Post from earlier today.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2018 15:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/489647#M127901</guid>
      <dc:creator>aknight1</dc:creator>
      <dc:date>2018-08-24T15:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/489653#M127904</link>
      <description>Do you know if it is fixed in the latest release? The link you posted was for 9.4m3.  What about 9.4m5?&lt;BR /&gt;</description>
      <pubDate>Fri, 24 Aug 2018 15:45:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/489653#M127904</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-08-24T15:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/489655#M127905</link>
      <description>&lt;P&gt;Sorry, I don't know.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2018 15:52:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/489655#M127905</guid>
      <dc:creator>aknight1</dc:creator>
      <dc:date>2018-08-24T15:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/489662#M127912</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/153219"&gt;@aknight1&lt;/a&gt;: I'm glad. And it only convinces me that it was reported much earlier than today.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2018 16:03:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/489662#M127912</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2018-08-24T16:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: Curious about FINDW / INDEXW results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/489707#M127932</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/153219"&gt;@aknight1&lt;/a&gt;: It's a veritable bug. This very example, &lt;EM&gt;verbatim&lt;/EM&gt;, was posted on SAS-L a month or so ago by Roger DeAngelis and discussed and taken apart ad nauseam. And I believe that as a result of the consensus it's been already reported. Which doesn't mean that it will be fixed any time soon, particularly since it's pretty subtle and materializes only under very specific conditions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This thread was started on 2018-07-13, which means 6 weeks ago. If you read this thread from the start, you will find that the bug was also reported to SAS TS on that day.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2018 17:19:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Curious-about-FINDW-INDEXW-results/m-p/489707#M127932</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-24T17:19:34Z</dc:date>
    </item>
  </channel>
</rss>

