<?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: Problem with Perl regular expression in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-Perl-regular-expression/m-p/374335#M276299</link>
    <description>&lt;P&gt;Post some examples of your nr field.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I posted my response based on:&lt;/P&gt;
&lt;PRE&gt;/* fails with */
data have;
  informat nr $80.;
  input id nr &amp;amp;;
  cards;
1  number: 6
2  number:5
3  number: 12
;

Data want;
set have;
o=prxparse('/(number:) \s*\d+/i');
start=1;stop=length(nr);
call prxnext(o,start,stop,nr,p,l);
NR=compress(substr(nr,p,l),,'kd');
  drop o start stop p l;
run;

/* but would work with */

data have;
  informat nr $80.;
  input id nr &amp;amp;;
  cards;
1  number: 6
2  number:5
3  number: 12
;

Data want;
set have;
o=prxparse('/(number:)\s*\d+/i');
start=1;stop=length(nr);
call prxnext(o,start,stop,nr,p,l);
NR=compress(substr(nr,p,l),,'kd');
  drop o start stop p l;
run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 09 Jul 2017 22:32:39 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-07-09T22:32:39Z</dc:date>
    <item>
      <title>Problem with Perl regular expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-Perl-regular-expression/m-p/374329#M276295</link>
      <description>&lt;P&gt;Ok i am literally stuck and dont understand this:&lt;/P&gt;
&lt;P&gt;I am running&amp;nbsp;a code with Perl regular expression:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data&amp;nbsp;want;
set&amp;nbsp;have;
o=prxparse('/(number:) \s*\d+/i');
start=1;stop=length(nr);
call prxnext(o,start,stop,nr,p,l);
NR=compress(substr(nr,p,l),,'kd');
&amp;nbsp; drop o start stop p l;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P class="p4"&gt;&lt;SPAN class="s3"&gt;The contents of nr looks like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p4"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p4"&gt;&lt;SPAN class="s3"&gt;NR&amp;nbsp;NUMBER: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;123456&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p4"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p4"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p4"&gt;&lt;SPAN class="s3"&gt;This is returning the following error:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p4"&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;750&amp;nbsp; Data Want;
751&amp;nbsp; set Have;
752&amp;nbsp; o=prxparse('/(number:) \s*\d+/i');
753 &amp;nbsp; start=1;stop=length(nr); l=1;
754 &amp;nbsp; call prxnext(o,start,stop,nr,p,l);
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -------
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 731
WARNING 731-185: Argument #5 is a character variable, while a numeric variable must be passed to
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; the PRXNEXT subroutine call in order for the variable to be updated.

754!&amp;nbsp; call prxnext(o,start,stop,nr,p,l);
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -------
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 731
WARNING 731-185: Argument #6 is a character variable, while a numeric variable must be passed to
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; the PRXNEXT subroutine call in order for the variable to be updated.

755&amp;nbsp; &amp;nbsp; *NR=compress(substr(nr,p,l),,'kd');
756&amp;nbsp; NR=substr(nr,p,l);
757&amp;nbsp; &amp;nbsp; drop o start stop p l;
758&amp;nbsp; run;

NOTE: Numeric values have been converted to character values at the places given by:
&amp;nbsp; &amp;nbsp; &amp;nbsp; (Line):(Column).
&amp;nbsp; &amp;nbsp; &amp;nbsp; 753:30
NOTE: Character values have been converted to numeric values at the places given by:
&amp;nbsp; &amp;nbsp; &amp;nbsp; (Line):(Column).
&amp;nbsp; &amp;nbsp; &amp;nbsp; 754:32 &amp;nbsp; 754:34 &amp;nbsp; 756:15 &amp;nbsp; 756:17
NOTE: Invalid second argument to function SUBSTR at line 756 column 4.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P class="p4"&gt;&lt;SPAN class="s3"&gt;Could anyone please advice me on this&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p4"&gt;&lt;SPAN class="s3"&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2017 22:06:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-Perl-regular-expression/m-p/374329#M276295</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2017-07-09T22:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Perl regular expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-Perl-regular-expression/m-p/374331#M276296</link>
      <description>&lt;P&gt;Just a further explanation&lt;/P&gt;
&lt;P&gt;i cant use the following&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;NR&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;compress&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;nr&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'kd'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There are other numbers in the nr column before the text 'nr number' that I want to exclude&lt;/P&gt;
&lt;P&gt;Thanks for your help&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2017 22:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-Perl-regular-expression/m-p/374331#M276296</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2017-07-09T22:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Perl regular expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-Perl-regular-expression/m-p/374332#M276297</link>
      <description>&lt;P&gt;Difficult to say without seeing your input data, but my guess is that you are inadvertently requiring an extra space. Try the following:&lt;/P&gt;
&lt;PRE&gt;Data want;
  set have;
  o=prxparse('/(number:)\s*\d+/i');
  start=1;stop=length(nr);
  call prxnext(o,start,stop,nr,p,l);
  NR=compress(substr(nr,p,l),,'kd');
  drop o start stop p l;
run;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2017 22:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-Perl-regular-expression/m-p/374332#M276297</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-09T22:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Perl regular expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-Perl-regular-expression/m-p/374334#M276298</link>
      <description>&lt;P&gt;Thanks, it shoudnt matter as I have&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;\s*&lt;/PRE&gt;
&lt;P&gt;I did try your code thoiugh and it is the same problem&lt;/P&gt;
&lt;P&gt;Any other suggesions please&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2017 22:26:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-Perl-regular-expression/m-p/374334#M276298</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2017-07-09T22:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Perl regular expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-Perl-regular-expression/m-p/374335#M276299</link>
      <description>&lt;P&gt;Post some examples of your nr field.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I posted my response based on:&lt;/P&gt;
&lt;PRE&gt;/* fails with */
data have;
  informat nr $80.;
  input id nr &amp;amp;;
  cards;
1  number: 6
2  number:5
3  number: 12
;

Data want;
set have;
o=prxparse('/(number:) \s*\d+/i');
start=1;stop=length(nr);
call prxnext(o,start,stop,nr,p,l);
NR=compress(substr(nr,p,l),,'kd');
  drop o start stop p l;
run;

/* but would work with */

data have;
  informat nr $80.;
  input id nr &amp;amp;;
  cards;
1  number: 6
2  number:5
3  number: 12
;

Data want;
set have;
o=prxparse('/(number:)\s*\d+/i');
start=1;stop=length(nr);
call prxnext(o,start,stop,nr,p,l);
NR=compress(substr(nr,p,l),,'kd');
  drop o start stop p l;
run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2017 22:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-Perl-regular-expression/m-p/374335#M276299</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-09T22:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Perl regular expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-Perl-regular-expression/m-p/374353#M276300</link>
      <description>&lt;P&gt;The notes and error messages seems pretty clear to me.&lt;/P&gt;
&lt;P&gt;Your code is expecting NR to be a character variable, but in your source dataset it is a number.&lt;/P&gt;
&lt;P&gt;Your code is expecting P to be a numeric variable, but in your source dataset it is a character string.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 03:30:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-Perl-regular-expression/m-p/374353#M276300</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-10T03:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Perl regular expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-Perl-regular-expression/m-p/374374#M276301</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;said, the messages are pretty clear &amp;nbsp;(except it is variables P and L which are the culprits) .&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 05:19:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-Perl-regular-expression/m-p/374374#M276301</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-07-10T05:19:02Z</dc:date>
    </item>
  </channel>
</rss>

