<?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: Prxmatch function for percent in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Prxmatch-function-for-percent/m-p/958335#M374048</link>
    <description>&lt;P&gt;Whether my suggested regular expression is "right" depends on your requirements, which are not exhaustively defined by the two example strings&amp;nbsp;&lt;SPAN&gt;"BAB 1,50%" (to be matched; or rather with a decimal point?) and&amp;nbsp;"BAB 1" (not to be matched). If my description&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;This matches a word boundary (&lt;FONT face="courier new,courier"&gt;\b&lt;/FONT&gt;) followed by the number "&lt;FONT face="courier new,courier"&gt;1&lt;/FONT&gt;" or "&lt;FONT face="courier new,courier"&gt;1.50&lt;/FONT&gt;", followed by a percent sign either directly or after&amp;nbsp;one or more space characters (e.g. "&lt;FONT face="courier new,courier"&gt;1&amp;nbsp; %&lt;/FONT&gt;").&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;is what you want, then, yes, the regex is right.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Feb 2025 10:41:10 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2025-02-05T10:41:10Z</dc:date>
    <item>
      <title>Prxmatch function for percent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prxmatch-function-for-percent/m-p/958321#M374041</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data like X="BAB 1,50%", I apply the prxmatch function&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if prxmatch("/\b1(\.50\%|\%|\s)/",X)&amp;gt;0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but I don't have the right result because I have in the output also the data with X="BAB 1".&amp;nbsp; How to improve the code to get the values with "%" ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you !&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 08:33:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prxmatch-function-for-percent/m-p/958321#M374041</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2025-02-05T08:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: Prxmatch function for percent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prxmatch-function-for-percent/m-p/958330#M374044</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286185"&gt;@SASdevAnneMarie&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286185"&gt;@SASdevAnneMarie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if prxmatch("/\b1(\.50\%|\%|\s)/",X)&amp;gt;0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;... I have in the output also the data with X="BAB 1".&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is because you didn't require a percent sign, but allowed a space character (&lt;FONT face="courier new,courier"&gt;\s&lt;/FONT&gt;) instead. You may want to allow one or more space characters &lt;EM&gt;between&lt;/EM&gt; the number and the percent sign:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;/\b1(\.50)?\s*%/&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;This matches a word boundary (&lt;FONT face="courier new,courier"&gt;\b&lt;/FONT&gt;) followed by the number "&lt;FONT face="courier new,courier"&gt;1&lt;/FONT&gt;" or "&lt;FONT face="courier new,courier"&gt;1.50&lt;/FONT&gt;", followed by a percent sign either directly or after&amp;nbsp;one or more space characters (e.g. "&lt;FONT face="courier new,courier"&gt;1&amp;nbsp; %&lt;/FONT&gt;").&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the percent sign does not need to be escaped with a backslash ("&lt;FONT face="courier new,courier"&gt;\%&lt;/FONT&gt;") and that the expression would &lt;EM&gt;not&lt;/EM&gt; match a number using a comma instead of the decimal point ("&lt;FONT face="courier new,courier"&gt;1&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;,&lt;/STRONG&gt;&lt;/FONT&gt;50%&lt;/FONT&gt;").&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 10:08:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prxmatch-function-for-percent/m-p/958330#M374044</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-02-05T10:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Prxmatch function for percent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prxmatch-function-for-percent/m-p/958332#M374046</link>
      <description>Thank you, FreelanceReinh, the right function is "/\b1(\.50)?\s*%/" ?</description>
      <pubDate>Wed, 05 Feb 2025 10:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prxmatch-function-for-percent/m-p/958332#M374046</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2025-02-05T10:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: Prxmatch function for percent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prxmatch-function-for-percent/m-p/958335#M374048</link>
      <description>&lt;P&gt;Whether my suggested regular expression is "right" depends on your requirements, which are not exhaustively defined by the two example strings&amp;nbsp;&lt;SPAN&gt;"BAB 1,50%" (to be matched; or rather with a decimal point?) and&amp;nbsp;"BAB 1" (not to be matched). If my description&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;This matches a word boundary (&lt;FONT face="courier new,courier"&gt;\b&lt;/FONT&gt;) followed by the number "&lt;FONT face="courier new,courier"&gt;1&lt;/FONT&gt;" or "&lt;FONT face="courier new,courier"&gt;1.50&lt;/FONT&gt;", followed by a percent sign either directly or after&amp;nbsp;one or more space characters (e.g. "&lt;FONT face="courier new,courier"&gt;1&amp;nbsp; %&lt;/FONT&gt;").&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;is what you want, then, yes, the regex is right.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 10:41:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prxmatch-function-for-percent/m-p/958335#M374048</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-02-05T10:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: Prxmatch function for percent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prxmatch-function-for-percent/m-p/958337#M374049</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286185"&gt;@SASdevAnneMarie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you, FreelanceReinh, the right function is "/\b1(\.50)?\s*%/" ?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I would be using single quotes for SAS to not interpret the percent sign as macro token.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In case you also want to cover values like 1.40, 1.3, 1.233333 etc. you could change the RegEx to&lt;/P&gt;
&lt;PRE&gt;'/\b1(\.\d+)? *%/'&lt;/PRE&gt;
&lt;P&gt;or even a bit broader to cover any percent values like 2 %, 12.5 $, 3.765333 %&lt;/P&gt;
&lt;PRE&gt;'/\b\d+(\.\d+)? *%/'&lt;/PRE&gt;
&lt;P&gt;I've replaced \s with a blank. \s stands for any whitespace character like tab etc. which I felt should not be included.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And of course if the string must start with BAB then the RegEx needs to include it.&lt;/P&gt;
&lt;PRE&gt;'/^BAB +\d+(\.\d+)? *%/'&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 10:54:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prxmatch-function-for-percent/m-p/958337#M374049</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2025-02-05T10:54:23Z</dc:date>
    </item>
  </channel>
</rss>

