<?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: Like Operator in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131299#M26767</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can try sounds like operator&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; create table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select a.* from have where&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; upcase(notes)=*"WORD";&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;jagadish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Sep 2013 16:19:44 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2013-09-06T16:19:44Z</dc:date>
    <item>
      <title>Like Operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131297#M26765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to find some words in a variable called notes. There are more than 100 words that I need to look for.Is there a better way to subsitue the following, instead of write 100 like statements?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; create table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select a.* from have where&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; upcase(notes) like '%WORD1%' or upcase(notes) like '%WORD2%' ......&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 16:14:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131297#M26765</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2013-09-06T16:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: Like Operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131298#M26766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. Can you put the words in a table and then merge with a like merge?&lt;/P&gt;&lt;P&gt;2. Use a datastep and then put the words in an array and use the whichc function?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 16:18:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131298#M26766</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-09-06T16:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: Like Operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131299#M26767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can try sounds like operator&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; create table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select a.* from have where&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; upcase(notes)=*"WORD";&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;jagadish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 16:19:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131299#M26767</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2013-09-06T16:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: Like Operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131300#M26768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I say WORD in my example I'm not looking exactly for WORD. Word1 can be a Lion ,Word2 can be water word3 can be Mars etc etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 16:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131300#M26768</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2013-09-06T16:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Like Operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131301#M26769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Lookup this fairly recent thread with similar topic:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" class="active_link" href="https://communities.sas.com/thread/46818"&gt;https://communities.sas.com/thread/46818&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would really need to provide additionnal details on why exactly you need to use the like operator and what the 100 words you are searching for resemble.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many like-operator jobs can be solved fairly easily with PERL (or PRX functions/routines in SAS) but the problem described reads as though you shouldn't use the like operator at all can could use a simple syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you could also use an array _temporary_ to act as a 100 word dictionary that you loop through for syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are also other solutions than like-operator and PERL such as the use of string distance functions such as complev and compged (levenstein and generalized edit distance)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Worst case scenario, you can always use macro to write your statement with like-operator. I doubt the like operator is very efficient but if your job is small and you are satisfied with the like operator results, that can be a fast and easy solution to writing the programming statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 16:30:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131301#M26769</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-09-06T16:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: Like Operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131302#M26770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Notes is a varible that contains complaints from customers. I identified a 100 different words in the complaints column and need to look for them and filter those records.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 16:31:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131302#M26770</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2013-09-06T16:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Like Operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131303#M26771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you&amp;nbsp; want to flag which word matches? what about multiple matches?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the array solution above is the simplest one to implement in a datastep from a programming standpoint. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;array words_to_find(100) $&amp;nbsp; {"Word1", "word2", "word3"....};&lt;/P&gt;&lt;P&gt;array flag_word(100) flag1-flag100;&lt;/P&gt;&lt;P&gt;do i=1 to 100;&lt;/P&gt;&lt;P&gt;if find(string, words_to_find(i))&amp;gt;0 then flag_word(i)=1; &lt;/P&gt;&lt;P&gt;else flag_word(i)=0;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;if sum(of flag_word(*))&amp;gt;0 then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 16:41:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131303#M26771</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-09-06T16:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Like Operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131304#M26772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm gettin this error after declaring array:&lt;/P&gt;&lt;P&gt;array words_to_find(100) $&amp;nbsp; {"Word1", "word2", "word3"....};&lt;/P&gt;&lt;P&gt;ERROR 391-185: Expecting a variable length specification&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 17:13:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131304#M26772</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2013-09-06T17:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Like Operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131305#M26773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wrong Brackets apparently ({ to ()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set sashelp.class;&lt;/P&gt;&lt;P&gt;array names_to_find(2) $ ("Alfred", "Jane");&lt;/P&gt;&lt;P&gt;array flag(2) flag1-flag2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do i = 1 to dim(names_to_find);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if name=names_to_find(i) then flag(i)=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else flag(i)=0;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 17:34:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131305#M26773</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-09-06T17:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Like Operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131306#M26774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;&lt;BR /&gt;SASPhile wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I'm trying to find some words in a variable called notes. There are more than 100 words that I need to look for.Is there a better way to subsitue the following, instead of write 100 like statements?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; create table want as&lt;/P&gt;
&lt;P&gt;&amp;nbsp; select a.* from have where&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; upcase(notes) like '%WORD1%' or upcase(notes) like '%WORD2%' ......&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rather than approach a SQL question with a data step solution, consider the benefits of placing those 100+ words to be searched for, into a table of their own. Then the information handling problem moves from the syntax layer&amp;nbsp; into the data layer, and PROC SQL can provide its solution with a simple join using the FIND() function, like&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select * from have &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;inner join word_list_table &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; on FIND( have.notes, word_list_table.word, 'IT' ) &amp;gt;0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;In that IT parameter the 'I' treats upper and lower case the same. and the 'T' removes trailing blanks from the WORD variable before making that search.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Read the documentation on the FIND() function at&amp;nbsp; &lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/64814/HTML/default/viewer.htm#p00ab6ey29t2i8n1ihel88tqtga9.htm"&gt;http://support.sas.com/documentation/cdl/en/lefunctionsref/64814/HTML/default/viewer.htm#p00ab6ey29t2i8n1ihel88tqtga9.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Sep 2013 10:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Like-Operator/m-p/131306#M26774</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2013-09-07T10:38:06Z</dc:date>
    </item>
  </channel>
</rss>

