<?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: Why this simple data step doesn't work? (findw/if/else) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-this-simple-data-step-doesn-t-work-findw-if-else/m-p/437027#M108776</link>
    <description>&lt;P&gt;Findw is a function for finding a word delimited by certain characters.&amp;nbsp; Comma is not a word, it is a delimiter.&amp;nbsp; If you want to find text in another you can use index() - these are all well described in the manual:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; _null&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
	&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;"Why, oh why"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
	containscomma=&lt;SPAN class="token keyword"&gt;ifn(index&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;","&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;),1,0);&lt;/SPAN&gt;
	&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt; containscomma&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note I use the binary choise ifn() function to simplfy the code.&amp;nbsp; Also, I do not put an operator after the index, basically if index finds the character then the result is a positive number, hence if positive number=true return first, else second.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Feb 2018 09:31:44 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-02-14T09:31:44Z</dc:date>
    <item>
      <title>Why this simple data step doesn't work? (findw/if/else)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-this-simple-data-step-doesn-t-work-findw-if-else/m-p/437025#M108775</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the &lt;STRONG&gt;input&lt;/STRONG&gt; variable contains a comma, then the &lt;STRONG&gt;containscomma&lt;/STRONG&gt;&amp;nbsp;variable should be set to 1:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null;
	input = "Why, oh why";
	if findw(input, ",") &amp;gt; 0 then do; containscomma=1; end;
	else containscomma=0;
	put containscomma;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It does contains a comma, yet&amp;nbsp;&lt;STRONG&gt;containscomma&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;is set to 0.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can someone please advise on how I can make the code work as intended?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2018 09:25:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-this-simple-data-step-doesn-t-work-findw-if-else/m-p/437025#M108775</guid>
      <dc:creator>EinarRoed</dc:creator>
      <dc:date>2018-02-14T09:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: Why this simple data step doesn't work? (findw/if/else)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-this-simple-data-step-doesn-t-work-findw-if-else/m-p/437027#M108776</link>
      <description>&lt;P&gt;Findw is a function for finding a word delimited by certain characters.&amp;nbsp; Comma is not a word, it is a delimiter.&amp;nbsp; If you want to find text in another you can use index() - these are all well described in the manual:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; _null&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
	&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;"Why, oh why"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
	containscomma=&lt;SPAN class="token keyword"&gt;ifn(index&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;","&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;),1,0);&lt;/SPAN&gt;
	&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt; containscomma&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note I use the binary choise ifn() function to simplfy the code.&amp;nbsp; Also, I do not put an operator after the index, basically if index finds the character then the result is a positive number, hence if positive number=true return first, else second.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2018 09:31:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-this-simple-data-step-doesn-t-work-findw-if-else/m-p/437027#M108776</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-14T09:31:44Z</dc:date>
    </item>
  </channel>
</rss>

