<?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/363204#M274338</link>
    <description>&lt;P&gt;something like this should work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'m/NA|N\/A/oi'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when you have N/A, you need to escape / by adding \ as / has different meaning&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; abc;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; var1 $;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;NA&lt;/P&gt;
&lt;P&gt;N-A&lt;/P&gt;
&lt;P&gt;N/A&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; abcd(drop=pat);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; abc;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;pat =prxparse(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'m/NA|N\/A/oi'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; prxmatch(pat, var1)&amp;gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; newval =&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'yes'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; newval =&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'no'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;for your query all you need is&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;pat =prxparse(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'m/NA|N\/A/oi'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; prxmatch(pat, var1)&amp;gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 31 May 2017 20:11:21 GMT</pubDate>
    <dc:creator>kiranv_</dc:creator>
    <dc:date>2017-05-31T20:11:21Z</dc:date>
    <item>
      <title>Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357959#M274324</link>
      <description>&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;alive&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;is the subject alive&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;died&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;died at hospice&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would want to get only those records that contain only "alive" and "dead" as values. for instance row 1 and 3 are records to output. how do we get this using regex?&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 15:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357959#M274324</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2017-05-11T15:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357962#M274325</link>
      <description>&lt;P&gt;Why a regex, there is no pattern matching simply:&lt;/P&gt;
&lt;PRE&gt;if upcase(variable) in ("ALIVE","DEAD") then ...&lt;/PRE&gt;
&lt;P&gt;However note that died != dead, even though we can understand the two are the same, there is no logical way the computer can know.&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 15:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357962#M274325</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-11T15:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357968#M274326</link>
      <description>&lt;P&gt;there are hunderds of words and later in time, the pattern matching may chnage and it is eaiser to have a regex&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 16:01:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357968#M274326</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2017-05-11T16:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357970#M274327</link>
      <description>&lt;P&gt;Sorry, still don't see it. &amp;nbsp;Regex is for pattern matching, it wont really help you find words from a list. If there are lots then put them in a dataset thus:&lt;/P&gt;
&lt;PRE&gt;data words;
  word="ALIVE"; output;
  word="DEAD"; output;
run;

proc sql;
  select  *
  from    HAVE
  where  YOUR_VARIABLE in (select * from WORDS);
quit;
&lt;/PRE&gt;
&lt;P&gt;Or you could do it in a format, or code generation, or by merging, but I don't see regex doing it.&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 16:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357970#M274327</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-11T16:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357981#M274328</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16600"&gt;@SASPhile&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;there are hunderds of words and later in time, the pattern matching may chnage and it is eaiser to have a regex&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your original post says:&lt;/P&gt;
&lt;P&gt;"I would want to get only those records that contain only "alive" and "dead" as values"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is exactly one word and confirmed by statement that rows 1 and 3 match (although whether you meant "died" instead of "dead" does come up).&lt;/P&gt;
&lt;P&gt;With "only "alive" and "dead" " what does is matter if there are hundreds of words? You said "only".&lt;/P&gt;
&lt;P&gt;It seems like you may not have clearly stated the problem or the desired result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 16:18:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357981#M274328</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-11T16:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357985#M274329</link>
      <description>&lt;P&gt;something like this in Regex should work. But what RW9 Suggests&amp;nbsp;is the right way to do as it is much cleaner and very easily mangeable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;$50.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;alive&lt;/P&gt;
&lt;P&gt;is the subject alive&lt;/P&gt;
&lt;P&gt;died&lt;/P&gt;
&lt;P&gt;died at hospice&lt;/P&gt;
&lt;P&gt;Nothing happened&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; c;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;IF&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; PRXMATCH(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"m/.*died.*|.*alive.*/oi"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, a) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;just add any word like&amp;nbsp;.*wordyouwant.* after the pipe i.e. |. Here dot indicates any character and * means it can be there 0 or more times.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;see this link for more explanation&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;A href="http://support.sas.com/kb/38/719.html" target="_blank"&gt;http://support.sas.com/kb/38/719.html&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 16:59:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357985#M274329</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-05-11T16:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357994#M274330</link>
      <description>&lt;P&gt;Tried this and worked out well!&lt;/P&gt;&lt;P&gt;^died\s*$|^alive\s*$/i&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 17:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357994#M274330</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2017-05-11T17:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357995#M274331</link>
      <description>&lt;P&gt;oh I think i did not read your&amp;nbsp;question&amp;nbsp;well. you want those words in the begining.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;^died\s*$|^alive\s*$/i.&lt;/P&gt;
&lt;P&gt;this will not catch if your variable value is like &amp;nbsp;"alive is good".&amp;nbsp;&amp;nbsp;It can search for your find word with no space, single space or multiple spaces&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you try the below one just in case to be safe aand this takes care of your word at beginning+space after that+ any other other word(may or may not be there)&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;PRXMATCH(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"m/^died\s+.*|^alive\s+.*/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, a) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 17:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357995#M274331</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-05-11T17:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357999#M274332</link>
      <description>&lt;P&gt;I want only those records contain just "died" and "alive"&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 17:39:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/357999#M274332</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2017-05-11T17:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/358003#M274333</link>
      <description>&lt;P&gt;for that your solution will work&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;. you can also try this&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;PRXMATCH(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"m/^died$|^alive$/i"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, trim(a)) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 17:59:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/358003#M274333</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-05-11T17:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/358010#M274334</link>
      <description>I imagine a table of the words required with one row for each word string&lt;BR /&gt;Proc sql ;&lt;BR /&gt;Create table required_subset as &lt;BR /&gt; Select distinct a.* &lt;BR /&gt; From what.you_have a&lt;BR /&gt;Join imagined_words b&lt;BR /&gt;On a.description_variable contains trim( b.word_string )&lt;BR /&gt;;&lt;BR /&gt;quit ;&lt;BR /&gt;I used DISTINCT expecting there _might_ be multiple matches in some cases</description>
      <pubDate>Thu, 11 May 2017 18:22:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/358010#M274334</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-05-11T18:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/358218#M274335</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16600"&gt;@SASPhile&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;there are hunderds of words and later in time, the pattern matching may chnage and it is eaiser to have a regex&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you know the required changes right now?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not, why use regex? With "hunderds of words" the expression will be difficult to read. Using a format or the suggest proc sql is imho the smarter solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 13:00:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/358218#M274335</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-05-12T13:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/358223#M274336</link>
      <description>&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;IF&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; PRXMATCH(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"/\b(died|alive)\b/oi"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, a) ;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 13:13:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/358223#M274336</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-12T13:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/363197#M274337</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;if there is a special character in the string and&amp;nbsp; i want to match it as part of the string,how to include in expression?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if var1 has the following values:&lt;/P&gt;&lt;P&gt;var1&lt;/P&gt;&lt;P&gt;NA&lt;/P&gt;&lt;P&gt;N-A&lt;/P&gt;&lt;P&gt;N/A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would want&amp;nbsp; to match NA and N/A only&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 19:48:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/363197#M274337</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2017-05-31T19:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/363204#M274338</link>
      <description>&lt;P&gt;something like this should work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'m/NA|N\/A/oi'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when you have N/A, you need to escape / by adding \ as / has different meaning&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; abc;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; var1 $;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;NA&lt;/P&gt;
&lt;P&gt;N-A&lt;/P&gt;
&lt;P&gt;N/A&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; abcd(drop=pat);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; abc;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;pat =prxparse(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'m/NA|N\/A/oi'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; prxmatch(pat, var1)&amp;gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; newval =&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'yes'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; newval =&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'no'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;for your query all you need is&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;pat =prxparse(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'m/NA|N\/A/oi'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; prxmatch(pat, var1)&amp;gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 20:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/363204#M274338</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-05-31T20:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/365763#M274339</link>
      <description>&lt;P&gt;if the text conatins the key words discretion and physician , but the oder they appear varies. But I want to captuare only those records which have both discretion and phsycian in the text.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can do a search by parsing the words in the order they might appear like as follows:&lt;/P&gt;&lt;P&gt;prxmatch("/(physician).*(discretion)|(&lt;SPAN&gt;discretion).*(physician)/oi",var_name).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;i'm looking for alternate method where instead of passing it two times,is there a way I capture the record by parsing the key words just once?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 16:33:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regex/m-p/365763#M274339</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2017-06-09T16:33:40Z</dc:date>
    </item>
  </channel>
</rss>

