<?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: Regex in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/397568#M96093</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below syntax would give the number of key words appearing in each observation. This can be modified to create 0/1 flag variables for each of the mentioned keyword.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want(drop=list);&lt;BR /&gt;set have;&lt;BR /&gt;num_keywords=0;&lt;BR /&gt;length list $50;&lt;BR /&gt;do list = 'decision', 'decide','sponsor', 'withdrawn'; &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if find(trim(text), trim(list),'i') &amp;gt; 0 then num_keywords+1;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Sep 2017 18:42:09 GMT</pubDate>
    <dc:creator>stat_sas</dc:creator>
    <dc:date>2017-09-20T18:42:09Z</dc:date>
    <item>
      <title>Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/397537#M96082</link>
      <description>&lt;P&gt;This is a sample of what the data looks like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input text $50.;
cards;
sponsor withdrawn
withdrawn by sponsor
decision taken by sponsor to withdraw
sponsor decided to withdraw
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The key words are: decision/decide, sponsor, withdrawn&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to efficiently search for key words in anyorder they appear?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Note: Edited by Reeza for clarity and legibility.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2017 17:31:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/397537#M96082</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2017-09-20T17:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/397542#M96085</link>
      <description>&lt;P&gt;Search for them one at a time:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;decide = find(longstring, 'decide',&amp;nbsp;, 'i') &amp;gt; 0;&lt;/P&gt;
&lt;P&gt;sponsor = find(longstring, 'sponsor', , 'i') &amp;gt; 0;&lt;/P&gt;
&lt;P&gt;withdraw = find(longstring, 'withdraw', , 'i') &amp;gt; 0;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gives you three variables, each either 0 or 1, indicating whether the string was found.&amp;nbsp; The 'i' modifier says to ignore upper case vs. lower case differences.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is possible to consider FINDW instead of FIND, but for your purposes it looks like FIND is better.&amp;nbsp; So the 0/1 value for the variable WITHDRAW indicates the presence of any of these strings:&amp;nbsp; withdraw, withdraws, withdrawn.&amp;nbsp; It does not locate "withdrew" however.&amp;nbsp; So create as many flags as are needed ... perhaps a separate one for "decision".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2017 17:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/397542#M96085</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-20T17:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/397546#M96087</link>
      <description>&lt;P&gt;It seems like you've been asking a few questions related to REGEX recently, so I thought this may be a useful reference:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://regex101.com/" target="_blank"&gt;https://regex101.com/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use it to build and test your strings.&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2017 17:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/397546#M96087</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-20T17:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/397568#M96093</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below syntax would give the number of key words appearing in each observation. This can be modified to create 0/1 flag variables for each of the mentioned keyword.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want(drop=list);&lt;BR /&gt;set have;&lt;BR /&gt;num_keywords=0;&lt;BR /&gt;length list $50;&lt;BR /&gt;do list = 'decision', 'decide','sponsor', 'withdrawn'; &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if find(trim(text), trim(list),'i') &amp;gt; 0 then num_keywords+1;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2017 18:42:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/397568#M96093</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2017-09-20T18:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/397656#M96123</link>
      <description>&lt;P&gt;the words in the list have to appear the way they are declared? what if the order changes?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 00:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/397656#M96123</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2017-09-21T00:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/397660#M96125</link>
      <description>&lt;P&gt;1. What should the output look like?&lt;/P&gt;
&lt;P&gt;2. RegEx bring no benefit for such a simple search. Consider using index() or find() as shown&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Fyi, the match string would be something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data HAVE;
input TEXT $50.;
MATCH=prxmatch('m/deci(sion|de)|sponsor|withdrawn/i',TEXT);
cards;
sponsor withdrawn
withdrawn by sponsor
decision taken by sponsor to withdraw
sponsor decided to withdraw
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 01:18:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/397660#M96125</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-09-21T01:18:47Z</dc:date>
    </item>
  </channel>
</rss>

