<?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 Using 'Not In' in  functions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-Not-In-in-functions/m-p/713025#M219913</link>
    <description>&lt;P&gt;I would like to understand how to use 'not in' in SCAN function. What would be wrong in the below code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5th word from filename is '0417' which is not equals to either '5601' or '6010' or '6020'.So I want value of source=filename in my output but I'm getting source='missing' in my output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let function=NL; 

data have;
filename = "IFT_GT_RND_2_0417_1_20201009T075212.csv";
if scan(lowcase(filename),-1,'.')='csv' and "&amp;amp;function" EQ 'NL' and not scan(lowcase(filename),5,'_') in ('5601','6010','6020') then do;
      source=filename;
end;
else source='missing';
run;&lt;/PRE&gt;</description>
    <pubDate>Thu, 21 Jan 2021 10:45:21 GMT</pubDate>
    <dc:creator>David_Billa</dc:creator>
    <dc:date>2021-01-21T10:45:21Z</dc:date>
    <item>
      <title>Using 'Not In' in  functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Not-In-in-functions/m-p/713025#M219913</link>
      <description>&lt;P&gt;I would like to understand how to use 'not in' in SCAN function. What would be wrong in the below code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5th word from filename is '0417' which is not equals to either '5601' or '6010' or '6020'.So I want value of source=filename in my output but I'm getting source='missing' in my output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let function=NL; 

data have;
filename = "IFT_GT_RND_2_0417_1_20201009T075212.csv";
if scan(lowcase(filename),-1,'.')='csv' and "&amp;amp;function" EQ 'NL' and not scan(lowcase(filename),5,'_') in ('5601','6010','6020') then do;
      source=filename;
end;
else source='missing';
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Jan 2021 10:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Not-In-in-functions/m-p/713025#M219913</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-01-21T10:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using 'Not In' in  functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Not-In-in-functions/m-p/713027#M219914</link>
      <description>&lt;P&gt;Maxim 2: Read the Log:&lt;/P&gt;
&lt;PRE&gt; 73         %let function=NL;
 74         
 75         data have;
 76         filename = "IFT_GT_RND_2_0417_1_20201009T075212.csv";
 77         if scan(lowcase(filename),-1,'.')='csv' and "&amp;amp;function" EQ 'NL' and not scan(lowcase(filename),5,'_') in
 77       ! ('5601','6010','6020') then do;
 78               source=filename;
 79         end;
 80         else source='missing';
 81         run;
 
 &lt;FONT color="#FF0000"&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
       77:69   77:73  &lt;/FONT&gt; 
&lt;/PRE&gt;
&lt;P&gt;This points to the fact that the NOT operator is resolved first, before the IN. So SAS needs to make a boolean (numeric) value out of the result of the character SCAN function.&lt;/P&gt;
&lt;P&gt;There are two ways to make this correct:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if scan(lowcase(filename),-1,'.')='csv' and "&amp;amp;function" EQ 'NL' and not (scan(lowcase(filename),5,'_') in ('5601','6010','6020')) then do;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if scan(lowcase(filename),-1,'.')='csv' and "&amp;amp;function" EQ 'NL' and scan(lowcase(filename),5,'_') not in ('5601','6010','6020') then do;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Jan 2021 10:55:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Not-In-in-functions/m-p/713027#M219914</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-21T10:55:22Z</dc:date>
    </item>
  </channel>
</rss>

