<?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: how to find a word in the variable in sas datastep in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/308998#M66404</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;findw requires atleast 2 arguments but i only have one&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Really?&lt;/P&gt;
&lt;P&gt;You have&lt;/P&gt;
&lt;P&gt;- a variable to search (var)&lt;/P&gt;
&lt;P&gt;- a string to search for ('SOMETH')&lt;/P&gt;
&lt;P&gt;So where's the problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
var = 'This is a text with SOMETH in it';
result = findw(var,'SOMETH');
run;

proc print noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;              var                   result

This is a text with SOMETH in it      21  
&lt;/PRE&gt;</description>
    <pubDate>Thu, 03 Nov 2016 12:58:50 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-11-03T12:58:50Z</dc:date>
    <item>
      <title>how to find a word in the variable in sas datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/308991#M66399</link>
      <description>&lt;P&gt;I have a dataset and in that a variable called var. In that i need extract observations which has a word "SOMETH". It may be first &amp;nbsp;word or middle or last. Can you please explain me how to do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried var=:"SOMETH" but it only gives if the word comes first.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 12:31:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/308991#M66399</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2016-11-03T12:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to find a word in the variable in sas datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/308992#M66400</link>
      <description>&lt;P&gt;If it is a separate word, look at the &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002978282.htm" target="_blank"&gt;findw&lt;/A&gt; function. If it may be part of a word, look at &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212242.htm" target="_blank"&gt;index&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 12:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/308992#M66400</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-11-03T12:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to find a word in the variable in sas datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/308994#M66401</link>
      <description>&lt;P&gt;findw requires atleast 2 arguments but i only have one&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 12:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/308994#M66401</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2016-11-03T12:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to find a word in the variable in sas datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/308995#M66402</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index("SOMETH", var) &amp;gt; 0 then output;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Nov 2016 12:52:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/308995#M66402</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2016-11-03T12:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to find a word in the variable in sas datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/308996#M66403</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sql Solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
set sashelp.class;
if mod(_n_,4)=1 then name_new=cats(name)||'SOMETHetc etc';
else if mod(_n_,4)=2 then name_new=cats(name)||'SOMETHetc';
else if mod(_n_,4)=3 then name_new=name||'SOMETH';
else name_new=name;
run;

proc sql;
select * from have
where name_new like '%SOMETH%';
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Nov 2016 12:54:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/308996#M66403</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2016-11-03T12:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to find a word in the variable in sas datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/308998#M66404</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;findw requires atleast 2 arguments but i only have one&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Really?&lt;/P&gt;
&lt;P&gt;You have&lt;/P&gt;
&lt;P&gt;- a variable to search (var)&lt;/P&gt;
&lt;P&gt;- a string to search for ('SOMETH')&lt;/P&gt;
&lt;P&gt;So where's the problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
var = 'This is a text with SOMETH in it';
result = findw(var,'SOMETH');
run;

proc print noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;              var                   result

This is a text with SOMETH in it      21  
&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Nov 2016 12:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/308998#M66404</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-11-03T12:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to find a word in the variable in sas datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/309052#M66433</link>
      <description>&lt;P&gt;And if your value may sometimes have different case and you want to match "Someth", "someth" or even "someTH" as well as exactly "SOMETH" your comparison would need to consider case:&lt;/P&gt;
&lt;P&gt;result &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;findw&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;( upcase(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;var)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'SOMETH'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Some actual concrete examples would help with input and desired result.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Note that your original search does not match "words".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;See this example:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
   informat str $15.;
   input str 1-15;
   if str =: 'SOMETH' then put "Found" Str=;
datalines;
SOMETH
SOMETHing
Someth ELSE
something 
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2016 17:38:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/309052#M66433</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-11-04T17:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to find a word in the variable in sas datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/309057#M66437</link>
      <description>&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Use this function if your var has mixed case.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;find(var,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"SOMETH"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,"i") &lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 15:18:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-a-word-in-the-variable-in-sas-datastep/m-p/309057#M66437</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2016-11-03T15:18:58Z</dc:date>
    </item>
  </channel>
</rss>

