<?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: Prematch didn't work while searching in the middle string? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Prematch-didn-t-work-while-searching-in-the-middle-string/m-p/623438#M183550</link>
    <description>&lt;P&gt;Looks like you based your code on another Communities answer where If_True and If_False wereactually part of the data. They are not part of any regex syntax. Here they are not so you will always see found=0. I have simplified your regex and this works for me. I hope it also work for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dataout;
  set datain;
  if prxmatch("m/.*?5648/i",name) &amp;gt; 0 then found=1;
  else if prxmatch("m/.*?9463/i",name) &amp;gt; 0 then found=2;
  else if prxmatch("m/.*?4721/i",name) &amp;gt; 0 then found=3;
  else found=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 09 Feb 2020 19:26:59 GMT</pubDate>
    <dc:creator>jklaverstijn</dc:creator>
    <dc:date>2020-02-09T19:26:59Z</dc:date>
    <item>
      <title>Prematch didn't work while searching in the middle string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prematch-didn-t-work-while-searching-in-the-middle-string/m-p/623435#M183547</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I use prematch function below.&amp;nbsp;&amp;nbsp; It seems like my program wasn't working.&amp;nbsp; How to fix it?&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datain;

format name $ 500.;

input name &amp;amp;;

cards;

CAR ID 5648MA

0009463

000-4721

;

run;

data dataout;
  set datain;
  if prxmatch("m/(?=.*?If_True)(?=.*?5648)/i",name) &amp;gt; 0 then found=1;
  else if prxmatch("m/(?=.*?If_True)(?=.*?9463)/i",name) &amp;gt; 0 then found=2;
  else if prxmatch("m/(?=.*?If_False)(?=.*?4721)/i",name) &amp;gt; 0 then found=3;
  else found=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 Feb 2020 18:48:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prematch-didn-t-work-while-searching-in-the-middle-string/m-p/623435#M183547</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-02-09T18:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: Prematch didn't work while searching in the middle string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prematch-didn-t-work-while-searching-in-the-middle-string/m-p/623438#M183550</link>
      <description>&lt;P&gt;Looks like you based your code on another Communities answer where If_True and If_False wereactually part of the data. They are not part of any regex syntax. Here they are not so you will always see found=0. I have simplified your regex and this works for me. I hope it also work for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dataout;
  set datain;
  if prxmatch("m/.*?5648/i",name) &amp;gt; 0 then found=1;
  else if prxmatch("m/.*?9463/i",name) &amp;gt; 0 then found=2;
  else if prxmatch("m/.*?4721/i",name) &amp;gt; 0 then found=3;
  else found=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Feb 2020 19:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prematch-didn-t-work-while-searching-in-the-middle-string/m-p/623438#M183550</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2020-02-09T19:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Prematch didn't work while searching in the middle string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prematch-didn-t-work-while-searching-in-the-middle-string/m-p/623530#M183589</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A simplier approach, assuming that the condition to flag the variable is to find the pattern anywhere in the string (no condition such as &amp;nbsp;the string ends with the pattern, ...)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dataout;
  set datain;
  if prxmatch("/5648/",name) &amp;gt; 0 then found=1;
  else if prxmatch("/9463/",name) &amp;gt; 0 then found=2;
  else if prxmatch("/4721/",name) &amp;gt; 0 then found=3;
  else found=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;-&amp;gt; no need to add the "i" modifier as you look for digits and not letters&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 09:03:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prematch-didn-t-work-while-searching-in-the-middle-string/m-p/623530#M183589</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-10T09:03:55Z</dc:date>
    </item>
  </channel>
</rss>

