<?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 question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PRXMatch-question/m-p/237487#M43535</link>
    <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;Your suggestion also makes sense. I think I'll add in the 'if/else if" qualifiers and play with it until I get the results I'm looking for. &lt;BR /&gt;&lt;BR /&gt;The longer I stare at the PRXMatch syntax the more it starts making sense.</description>
    <pubDate>Wed, 02 Dec 2015 23:03:07 GMT</pubDate>
    <dc:creator>Ody</dc:creator>
    <dc:date>2015-12-02T23:03:07Z</dc:date>
    <item>
      <title>PRXMatch question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXMatch-question/m-p/237465#M43529</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I recently posted a question about phone number validation, etc, and was referred to this article:&amp;nbsp;&lt;A href="https://heuristically.wordpress.com/2012/10/30/phone-number-validation-in-sas/" target="_blank" rel="nofollow"&gt;https://heuristically.wordpress.com/2012/10/30/pho&lt;WBR /&gt;ne-number-validation-in-sas/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's a great article and the program works fine, however, when i look through my results I'm not getting the flags I would expect based on how that portion of the program is written.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* A=area code not in service */
    if substr(&amp;amp;sm_phone_number, 1, 3) not in (&amp;amp;mv_npa) then &amp;amp;sm_exception = 'A'; 
 
    /* R=repeating number like 5555555555 is a probable fake */
    if prxmatch('/^([0-9])(\1{9})$/', strip(&amp;amp;sm_phone_number)) eq 1 then &amp;amp;sm_exception = 'R'; 
 
    /* I=Skype and Google GMail phone numbers do not allow inbound calls */
    if &amp;amp;sm_phone_number in ('2025808200', '7607058888') then &amp;amp;sm_exception = 'I'; 
 
    /* D=directory assistance &amp;lt;https://en.wikipedia.org/wiki/555-1212&amp;gt; */
    if prxmatch('/^[0-9]{3}5551212$/', trim(&amp;amp;sm_phone_number)) eq 1 then &amp;amp;sm_exception = 'D'; 
 
    /* F=numbers specifically reserved for fictional use are "555-0100" through "555-0199" */
    if prxmatch('/^[2-9][0-8][0-9]55501[0-9]{2}$/', strip(&amp;amp;sm_phone_number)) eq 1 then &amp;amp;sm_exception = 'F'; /* fake */
 
    /* 1=the last two digits of NXX cannot both be 1, to avoid confusion with the N11 
     * codes (http://en.wikipedia.org/wiki/North_American_Numbering_Plan) 
     * Only non-geographic area codes, such as toll-free 800/888/877/866/855 numbers 
     * and 900 numbers may use N11 as the telephone exchange prefix, since 
     * the area code must always be dialed for these numbers. 
     * &amp;lt;https://en.wikipedia.org/wiki/N11_code&amp;gt; */
    if (prxmatch('/^(800|888|877|866|855|900)/', strip(&amp;amp;sm_phone_number)) ne 1) and
        (prxmatch('/^[2-9][0-8][0-9][2-9]11[0-9]{4}\b/', strip(&amp;amp;sm_phone_number)) eq 1) then &amp;amp;sm_exception = '1';
 
    /* S=basic NANP syntax */
    if prxmatch('/^\(?[2-9][0-8][0-9]\)? ?[2-9][0-9]{2}-?[0-9]{4}\b/', strip(&amp;amp;sm_phone_number)) ne 1 then &amp;amp;sm_exception = 'S'; &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, all phone numbers in my dataset with sequential numbers like '000000000' or '9999999998', etc, are being flagged as "S" instead of "R" and I can't figure out why. I've been reading all the literature online regarding PRXMatch but it's not clicking for me.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A thought just occured to me, could this be because my phone number fields are all text?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I appreciate any insight into this. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2015 20:59:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXMatch-question/m-p/237465#M43529</guid>
      <dc:creator>Ody</dc:creator>
      <dc:date>2015-12-02T20:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: PRXMatch question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXMatch-question/m-p/237472#M43531</link>
      <description>Please explain the purpose of your code, such as what is S, A, R? Ideally provide some sample data, expected outcome and the outcome you get for now.</description>
      <pubDate>Wed, 02 Dec 2015 21:29:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXMatch-question/m-p/237472#M43531</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-12-02T21:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: PRXMatch question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXMatch-question/m-p/237478#M43532</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/29074"&gt;@Ody﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have a series of IF-THEN statements without ELSE statements. So, if one "phone number" satisfies more than one IF condition, it will receive the flag of the &lt;U&gt;last&lt;/U&gt; condition met. (The flag is overwritten each time a match is detected.) Hence, every number satisfying the 'S' condition (the &lt;EM&gt;last&lt;/EM&gt; in the list) will get the 'S' flag, regardless of other flags it may have temporarily received before, when the other conditions were checked.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your concrete examples, &lt;SPAN&gt;'000000000' or '9999999998' apparently must have satisfied the 'S' condition. In fact, they do not meet the 'R' condition (but they would receive the 'S' flag nevertheless even if they did): '000000000' has only 9 digits, but 10 are necessary to get the 'R' flag.&amp;nbsp;'9999999998' does not consist of 10 repeated digits, it has nine 9s and one 8. Even if it had ten 9s and one 8 or eleven 9s (and no &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; it would not meet the 'R' criterion, because the regular expression used there requires exactly 10 repeated digits in a row, so it is fairly restrictive.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is fine that your phone numbers are&amp;nbsp;stored as text. Otherwise, the&amp;nbsp;application of the character functions SUBSTR, STRIP, etc. to them would enforce automatic numeric-to-character conversions.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2015 21:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXMatch-question/m-p/237478#M43532</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-12-02T21:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: PRXMatch question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXMatch-question/m-p/237479#M43533</link>
      <description>&lt;P&gt;&lt;SPAN&gt; '000000000' doesn't match&amp;nbsp;'/^\(?[2-9][0-8][0-9]\)? ?[2-9][0-9]{2}-?[0-9]{4}\b/' and that test is performed last, so it sets the flag to 'S'.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you want the flag from the first positive test, you should use a&amp;nbsp;&lt;STRONG&gt;if - else if - else if - else&lt;/STRONG&gt; construct.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2015 22:06:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXMatch-question/m-p/237479#M43533</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-12-02T22:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: PRXMatch question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXMatch-question/m-p/237485#M43534</link>
      <description>@FreelanceReinhard&lt;BR /&gt;&lt;BR /&gt;Makes sense. I thought that might be the case so I commented out the last condition and that defaulted the flags on all the mostly sequential numbers to "A" which matches that condition.</description>
      <pubDate>Wed, 02 Dec 2015 23:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXMatch-question/m-p/237485#M43534</guid>
      <dc:creator>Ody</dc:creator>
      <dc:date>2015-12-02T23:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: PRXMatch question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXMatch-question/m-p/237487#M43535</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;Your suggestion also makes sense. I think I'll add in the 'if/else if" qualifiers and play with it until I get the results I'm looking for. &lt;BR /&gt;&lt;BR /&gt;The longer I stare at the PRXMatch syntax the more it starts making sense.</description>
      <pubDate>Wed, 02 Dec 2015 23:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXMatch-question/m-p/237487#M43535</guid>
      <dc:creator>Ody</dc:creator>
      <dc:date>2015-12-02T23:03:07Z</dc:date>
    </item>
  </channel>
</rss>

