<?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: Perl Regular Expressions in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Perl-Regular-Expressions-in-SAS/m-p/686398#M208271</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215749"&gt;@Romeo1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are several issuses with your code.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;A Proc SQL step is terminated with a QUIT statement, nor a RUN statement.&lt;/LI&gt;
&lt;LI&gt;In Proc SQL a comma is useed to separate columns, so a comma after the last variable will generate a syntax error.&lt;/LI&gt;
&lt;LI&gt;A perl regular expression must be enclosed in /.../, the last is missing in your code.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Your expression works as expected&amp;nbsp;When these errors are corrected. I suggest a couple of modifications as shown in the following code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The i modifier at the end of the regular expression instructs prxmatch to ignore case, so both BE and be is correct.&lt;/P&gt;
&lt;P&gt;The dollar sign in the expression marks end of data just as ^ marks beginning of data. Combined with trimming of the ingoing variable it ensures that a match is found only if the string has exact 14 characters as specified in the expression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
	input c_bi $20.;
datalines;
SSSSSSSSSSA030
R020782/492008
R010114/970308
R006767/653308
000164063BE033
000164063be033
000264063LA021
000264063LA0212
000264063LA02
;
run;

proc sql;
	create table want as
		select 	
			c_bi, 
			prxmatch('/^[0-9]{9}[a-z]{2}[0-9]{3}$/i',trim(c_bi)) as c_bi_dum
from have;
quit;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="prxmatch.gif" style="width: 321px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/49754i97500C923F601DCF/image-size/large?v=v2&amp;amp;px=999" role="button" title="prxmatch.gif" alt="prxmatch.gif" /&gt;&lt;/span&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 24 Sep 2020 14:56:11 GMT</pubDate>
    <dc:creator>ErikLund_Jensen</dc:creator>
    <dc:date>2020-09-24T14:56:11Z</dc:date>
    <item>
      <title>Perl Regular Expressions in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Perl-Regular-Expressions-in-SAS/m-p/686360#M208250</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*I want write a general expression for a code with this characteristics bellow:
9 NUMBERS NUMBERS FROM (0-9), 2 LETTES FROM (A-Z) AND 3 NUMBERS FROM (0-9), e.g: 000028393OE123
The code below is not working for the expression that i did.&lt;BR /&gt;&lt;BR /&gt;c_bi: &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SSSSSSSSSSA030 - WRONG &lt;BR /&gt;R020782/492008 - WRONG &lt;BR /&gt;R010114/970308 - WRONG &lt;BR /&gt;R006767/653308 - WRONG &lt;BR /&gt;000164063BE033 - CORRECT &lt;BR /&gt;000264063LA021 - CORRECT &lt;BR /&gt;*/

proc sql;
create table a as
select 	c_bi, 
		prxmatch('/^[0-9]{9}[a-zA-Z]{2}[0-9]{3}',c_bi) 	as c_bi_dum,
from pdc.pdc_cli_bancarizacao 
where length(c_bi)=14 and 
c_nif='' and 
c_passaporte='' and 
cartao_residencia='' and 
cedula_pessoal='' and	
outro_documento='' and 	
numero_documento=''
order by c_bi desc;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Sep 2020 13:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Perl-Regular-Expressions-in-SAS/m-p/686360#M208250</guid>
      <dc:creator>Romeo1</dc:creator>
      <dc:date>2020-09-24T13:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Regular Expressions in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Perl-Regular-Expressions-in-SAS/m-p/686362#M208252</link>
      <description>&lt;P&gt;People are going to want you to post some example data. Include what you have, fictitious or not, and what you expect.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 13:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Perl-Regular-Expressions-in-SAS/m-p/686362#M208252</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2020-09-24T13:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Regular Expressions in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Perl-Regular-Expressions-in-SAS/m-p/686367#M208257</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;already include the expression called "c_bi" for wrong and correct expression. I think with that they can help me.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 13:29:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Perl-Regular-Expressions-in-SAS/m-p/686367#M208257</guid>
      <dc:creator>Romeo1</dc:creator>
      <dc:date>2020-09-24T13:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Regular Expressions in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Perl-Regular-Expressions-in-SAS/m-p/686398#M208271</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215749"&gt;@Romeo1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are several issuses with your code.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;A Proc SQL step is terminated with a QUIT statement, nor a RUN statement.&lt;/LI&gt;
&lt;LI&gt;In Proc SQL a comma is useed to separate columns, so a comma after the last variable will generate a syntax error.&lt;/LI&gt;
&lt;LI&gt;A perl regular expression must be enclosed in /.../, the last is missing in your code.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Your expression works as expected&amp;nbsp;When these errors are corrected. I suggest a couple of modifications as shown in the following code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The i modifier at the end of the regular expression instructs prxmatch to ignore case, so both BE and be is correct.&lt;/P&gt;
&lt;P&gt;The dollar sign in the expression marks end of data just as ^ marks beginning of data. Combined with trimming of the ingoing variable it ensures that a match is found only if the string has exact 14 characters as specified in the expression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
	input c_bi $20.;
datalines;
SSSSSSSSSSA030
R020782/492008
R010114/970308
R006767/653308
000164063BE033
000164063be033
000264063LA021
000264063LA0212
000264063LA02
;
run;

proc sql;
	create table want as
		select 	
			c_bi, 
			prxmatch('/^[0-9]{9}[a-z]{2}[0-9]{3}$/i',trim(c_bi)) as c_bi_dum
from have;
quit;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="prxmatch.gif" style="width: 321px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/49754i97500C923F601DCF/image-size/large?v=v2&amp;amp;px=999" role="button" title="prxmatch.gif" alt="prxmatch.gif" /&gt;&lt;/span&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Sep 2020 14:56:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Perl-Regular-Expressions-in-SAS/m-p/686398#M208271</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2020-09-24T14:56:11Z</dc:date>
    </item>
  </channel>
</rss>

