<?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 How to set a user-defined pattern to be checked by like/contains condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-user-defined-pattern-to-be-checked-by-like-contains/m-p/138647#M27984</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a small problem, I have a large data set and I want to take these values that have certain characters (in my case - prefixes). There are dozens of these prefixes so doing LIKE/CONTAINS each time does not only take space but is inefficient.. Prefixes usually look like that - NLLL - so 1 number and 3 letters. Is there a way to check for that pattern in like/contains coditions or just a way to have these conditions contain multiple values i.e. IN option with prefixes or a list of prefixes that could be checked instead of only one? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Oct 2014 09:27:17 GMT</pubDate>
    <dc:creator>Dontik</dc:creator>
    <dc:date>2014-10-23T09:27:17Z</dc:date>
    <item>
      <title>How to set a user-defined pattern to be checked by like/contains condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-user-defined-pattern-to-be-checked-by-like-contains/m-p/138647#M27984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a small problem, I have a large data set and I want to take these values that have certain characters (in my case - prefixes). There are dozens of these prefixes so doing LIKE/CONTAINS each time does not only take space but is inefficient.. Prefixes usually look like that - NLLL - so 1 number and 3 letters. Is there a way to check for that pattern in like/contains coditions or just a way to have these conditions contain multiple values i.e. IN option with prefixes or a list of prefixes that could be checked instead of only one? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 09:27:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-user-defined-pattern-to-be-checked-by-like-contains/m-p/138647#M27984</guid>
      <dc:creator>Dontik</dc:creator>
      <dc:date>2014-10-23T09:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a user-defined pattern to be checked by like/contains condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-user-defined-pattern-to-be-checked-by-like-contains/m-p/138648#M27985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, have a look at perl regular expressions - prxparse/prxmatch.&amp;nbsp; You could also break it out a bit:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (substr(PREFIX,1,1) in ('1','2','3'))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (substr(PREFIX(2,3) in ('ABC','CBD'));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;If you have lots, then make a dataset of the combinations and use that to generate your code from:&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set list_of_combinations end=last;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_=1 then call execute('data want; set have; where prefix in ("'||strip(item)||'");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else call execute(',"'||strip(item)||'"');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if last then call execute('); run;');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 09:41:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-user-defined-pattern-to-be-checked-by-like-contains/m-p/138648#M27985</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-10-23T09:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a user-defined pattern to be checked by like/contains condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-user-defined-pattern-to-be-checked-by-like-contains/m-p/138649#M27986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you don't have too many different patterns then a Regular Expression could be quite efficient for coding. Eg. for your pattern - NLLL - it could be something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; where prxmatch('/^\d[[:alpha:]]{3}/o',&lt;EM&gt;&amp;lt;your variable&amp;gt;&lt;/EM&gt;)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 10:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-a-user-defined-pattern-to-be-checked-by-like-contains/m-p/138649#M27986</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-10-23T10:46:34Z</dc:date>
    </item>
  </channel>
</rss>

