<?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: Variable not in string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-in-string/m-p/389320#M93354</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var1 $ not_in $;
not_in_flg = ifc(index(not_in, trim(var1)), 'N', 'Y');
cards;
A A,B,C
D A,B,C
E B,D,A
;
proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The last row of your example is wrong.&lt;/P&gt;</description>
    <pubDate>Sat, 19 Aug 2017 15:09:43 GMT</pubDate>
    <dc:creator>WarrenKuhfeld</dc:creator>
    <dc:date>2017-08-19T15:09:43Z</dc:date>
    <item>
      <title>Variable not in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-in-string/m-p/389316#M93353</link>
      <description>&lt;P&gt;Hi, In my "HAVE" dataset, if "var1" is not in the string "not_in", I'd like to tag it as "Y", as in the the "WANT" dataset.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need help to produce my "WANT" dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input var1 $ not_in $;&lt;BR /&gt;cards;&lt;BR /&gt;A A,B,C&lt;BR /&gt;D A,B,C&lt;BR /&gt;E B,D,A&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thus, for the first row, since A is in A,B,C, then I'd like its not_in_flg to be "N".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the second row, since D is not in A,B,C, then is not_in_flg is to be "Y".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;input var1 $ not_in $ not_in_flg $;&lt;BR /&gt;cards;&lt;BR /&gt;A A,B,C N&lt;BR /&gt;D A,B,C Y&lt;BR /&gt;E B,D,A N&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Aug 2017 14:15:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-not-in-string/m-p/389316#M93353</guid>
      <dc:creator>angeliquec</dc:creator>
      <dc:date>2017-08-19T14:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: Variable not in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-in-string/m-p/389320#M93354</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var1 $ not_in $;
not_in_flg = ifc(index(not_in, trim(var1)), 'N', 'Y');
cards;
A A,B,C
D A,B,C
E B,D,A
;
proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The last row of your example is wrong.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Aug 2017 15:09:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-not-in-string/m-p/389320#M93354</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-08-19T15:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: Variable not in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-in-string/m-p/389331#M93355</link>
      <description>&lt;P&gt;Is your data always a single character? If not use FINDW or INDEXW to search for a word and return it. Make sure to look at the later parameters for those functions to set them to ignore case or use UPCASE/LOWCASE to make everything the same case.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Aug 2017 16:51:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-not-in-string/m-p/389331#M93355</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-19T16:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Variable not in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-in-string/m-p/389371#M93361</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use find function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var1 $ not_in $;
If FIND(not_in,STRIP(var1),'i')=0 then flag="Y";
ELSE Flag="N";
cards;
A A,B,C
D A,B,C
E B,D,A
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Aug 2017 02:25:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-not-in-string/m-p/389371#M93361</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2017-08-20T02:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: Variable not in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-in-string/m-p/389372#M93362</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
set have;
if findw(not_in, var1," ,","ti") then notInFlg = "N";
else notInFlg = "Y";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Aug 2017 02:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-not-in-string/m-p/389372#M93362</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-08-20T02:40:01Z</dc:date>
    </item>
  </channel>
</rss>

