<?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: SAS Programming (Comparing two character variable) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Programming-Comparing-two-character-variable/m-p/253851#M48331</link>
    <description>&lt;P&gt;Here are a couple of choices.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if findw(trim(C), trim(B), ',') &amp;gt; 0 then d=1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;else d=0;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if findw(trim(C), trim(B), ',', 'i') &amp;gt; 0 then d=1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;else d=0;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "i" option will ignore upper vs. lower case, and would return 1 for the third observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that there are pitfalls that have to be addressed.&amp;nbsp; Since B takes on different lengths, I would assume you want to ignore trailing blanks that are part of B.&amp;nbsp; And INDEX searches for strings, not words.&amp;nbsp; So this comparison is true:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if index('abc,def', 'b') &amp;gt; 0 then D=1;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Mar 2016 15:51:28 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-03-02T15:51:28Z</dc:date>
    <item>
      <title>SAS Programming (Comparing two character variable)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Programming-Comparing-two-character-variable/m-p/253831#M48323</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;I stuck &amp;nbsp;on one of the point.please help me out&amp;nbsp;&lt;img id="smileyfrustrated" class="emoticon emoticon-smileyfrustrated" src="https://communities.sas.com/i/smilies/16x16_smiley-frustrated.png" alt="Smiley Frustrated" title="Smiley Frustrated" /&gt;&lt;/P&gt;&lt;P&gt;Scenario is We have two different variable in a dataset(Have) just like below&lt;/P&gt;&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp;B &amp;nbsp; &amp;nbsp; C&lt;/P&gt;&lt;P&gt;AA &amp;nbsp; &amp;nbsp;w &amp;nbsp; a,b,c,d&lt;/P&gt;&lt;P&gt;BB &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 1,0,Null&lt;/P&gt;&lt;P&gt;CC &amp;nbsp;aa &amp;nbsp; &amp;nbsp;AA,BBB,CCCC&lt;/P&gt;&lt;P&gt;DD &amp;nbsp; ab &amp;nbsp; a,b,c,d&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a dataset (Want) as if the B varibale is part of c variable then create a flag as D and mark that as 1 else o&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp;B &amp;nbsp; &amp;nbsp; C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; D&lt;/P&gt;&lt;P&gt;AA &amp;nbsp; &amp;nbsp;w &amp;nbsp; a,b,c,d &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;BB &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 1,0,Null &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;CC &amp;nbsp;aa &amp;nbsp; &amp;nbsp;AA,BBB,CCCC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;DD &amp;nbsp; ab &amp;nbsp; a,b,c,d &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 15:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Programming-Comparing-two-character-variable/m-p/253831#M48323</guid>
      <dc:creator>Dd07</dc:creator>
      <dc:date>2016-03-02T15:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Programming (Comparing two character variable)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Programming-Comparing-two-character-variable/m-p/253838#M48325</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well, no code as not typing in that test data. &amp;nbsp;You can check if the text appears in the string something like:&lt;/P&gt;
&lt;P&gt;if index(c,b)&amp;gt;0 then d=1;&lt;/P&gt;
&lt;P&gt;else d=0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However your row CC, it is not logical the text "aa" is not found in the other string. &amp;nbsp;Do you have another rule you didn't mention which allow upper case to equal lower case, if so:&lt;/P&gt;
&lt;P&gt;if index(upcase(c),upcase(b))&amp;gt;0 then d=1;&lt;/P&gt;
&lt;P&gt;else d=0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 15:24:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Programming-Comparing-two-character-variable/m-p/253838#M48325</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-02T15:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Programming (Comparing two character variable)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Programming-Comparing-two-character-variable/m-p/253851#M48331</link>
      <description>&lt;P&gt;Here are a couple of choices.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if findw(trim(C), trim(B), ',') &amp;gt; 0 then d=1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;else d=0;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if findw(trim(C), trim(B), ',', 'i') &amp;gt; 0 then d=1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;else d=0;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "i" option will ignore upper vs. lower case, and would return 1 for the third observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that there are pitfalls that have to be addressed.&amp;nbsp; Since B takes on different lengths, I would assume you want to ignore trailing blanks that are part of B.&amp;nbsp; And INDEX searches for strings, not words.&amp;nbsp; So this comparison is true:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if index('abc,def', 'b') &amp;gt; 0 then D=1;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 15:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Programming-Comparing-two-character-variable/m-p/253851#M48331</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-02T15:51:28Z</dc:date>
    </item>
  </channel>
</rss>

