<?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: Looking for consecutive numeric characters in a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62833#M13661</link>
    <description>ideal challenge for perl regular expression.</description>
    <pubDate>Mon, 10 Aug 2009 07:49:14 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2009-08-10T07:49:14Z</dc:date>
    <item>
      <title>Looking for consecutive numeric characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62832#M13660</link>
      <description>Hi, I would just like to ask if there's a function in SAS that can look for 10 consecutive numeric characters in a string?&lt;BR /&gt;
&lt;BR /&gt;
Example:&lt;BR /&gt;
&lt;BR /&gt;
I have a table with 2 columns..Column A contains the following data:&lt;BR /&gt;
&lt;BR /&gt;
01234567890ABC&lt;BR /&gt;
01234ABC567890&lt;BR /&gt;
01ABC23456789001&lt;BR /&gt;
&lt;BR /&gt;
I wanted to populate Column B with a value that depends on whether there are 10 consecutive numeric characters in a string in Column A. I'm looking for a SAS function that may be able to help me with this (something like findc), as im avoiding using arrays or checking each character as it might be process intensive specially when alot of observations are already involved.&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance.&lt;BR /&gt;
&lt;BR /&gt;
Edit: I'm using SAS 9.1 and looking to do this in a data step if possible.

Message was edited by: jpmoreno</description>
      <pubDate>Mon, 10 Aug 2009 06:53:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62832#M13660</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-10T06:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for consecutive numeric characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62833#M13661</link>
      <description>ideal challenge for perl regular expression.</description>
      <pubDate>Mon, 10 Aug 2009 07:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62833#M13661</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-08-10T07:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for consecutive numeric characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62834#M13662</link>
      <description>thanks!!, I'll post updates once i got the code going.</description>
      <pubDate>Mon, 10 Aug 2009 09:57:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62834#M13662</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-10T09:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for consecutive numeric characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62835#M13663</link>
      <description>Hey Peter/jpmoreno,&lt;BR /&gt;
the code for this problem in regular expression is very very simple. 10 time \d would get things going. &lt;BR /&gt;
&lt;BR /&gt;
data d1;&lt;BR /&gt;
input id $40.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
01234567890ABC&lt;BR /&gt;
01234ABC567890&lt;BR /&gt;
01ABC23456789001&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data dx;&lt;BR /&gt;
set d1;&lt;BR /&gt;
re=prxparse('/\d\d\d\d\d\d\d\d\d\d/');&lt;BR /&gt;
if prxmatch(re,id) then output;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print;run;&lt;BR /&gt;
&lt;BR /&gt;
Maybe you guys already got the solution but couldn't stop myself writting a perl regex..i rarely get to write regex these day....it's so tempting and cool.. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Thu, 13 Aug 2009 21:52:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62835#M13663</guid>
      <dc:creator>SushilNayak</dc:creator>
      <dc:date>2009-08-13T21:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for consecutive numeric characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62836#M13664</link>
      <description>It is better to call prxparse once only.&lt;BR /&gt;
&lt;BR /&gt;
data dx1;&lt;BR /&gt;
retain re;&lt;BR /&gt;
if _N_=1 then re=prxparse('/\d{10}/');&lt;BR /&gt;
set d1;&lt;BR /&gt;
if prxmatch(re,id) then output;&lt;BR /&gt;
run;</description>
      <pubDate>Thu, 13 Aug 2009 22:32:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62836#M13664</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-08-13T22:32:55Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for consecutive numeric characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62837#M13665</link>
      <description>Hey Chris,&lt;BR /&gt;
you're right...totally forgot how to lessen the \d ...as i said, don't get to write perl regex these days...totally forgot about this &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; &lt;BR /&gt;
&lt;BR /&gt;
Thanks for the updated regex!</description>
      <pubDate>Fri, 14 Aug 2009 17:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62837#M13665</guid>
      <dc:creator>SushilNayak</dc:creator>
      <dc:date>2009-08-14T17:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for consecutive numeric characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62838#M13666</link>
      <description>No worries, many ways to skin a cat. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
I was refering to the &lt;B&gt;if _N_=1 then&lt;/B&gt; test. &lt;BR /&gt;
Calling prxparse repeatedly is not advised.</description>
      <pubDate>Sun, 16 Aug 2009 09:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62838#M13666</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-08-16T09:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for consecutive numeric characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62839#M13667</link>
      <description>&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ah that one ....the use of IF _N_ = 1 then do; or W/O it doesn't makes any difference( thank god i remember this &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ) coz for constant regular expression the compilation happens only once and the value to the left side variable would be same for next successive observations as was for 1st observation. So successive calls to PRXPARSE will not cause a recompile, but will return the same value to the left side variable for the regular expression that was already compiled. &lt;BR /&gt;
Again, as you said - "many ways to skin a cat" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ..w/ or w/o doesn't makes any difference in case of constant regular expression like the one above.&lt;BR /&gt;
&lt;BR /&gt;
Thanks Chris, for pointing that out &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Sun, 16 Aug 2009 10:43:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62839#M13667</guid>
      <dc:creator>SushilNayak</dc:creator>
      <dc:date>2009-08-16T10:43:21Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for consecutive numeric characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62840#M13668</link>
      <description>Mmm, I didn't know that. It's a nice improvement on rxparse. &lt;BR /&gt;
rxparse would eat up all the memory and abort the data step.&lt;BR /&gt;
Cheers for the heads up.</description>
      <pubDate>Tue, 18 Aug 2009 01:05:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62840#M13668</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-08-18T01:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for consecutive numeric characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62841#M13669</link>
      <description>yes we got something like this, thanks!. I really didn't know about these kind of stuffs(regular expression) before I posted, luckily Peter gave me an idea where to look/research. Thanks everyone!</description>
      <pubDate>Tue, 18 Aug 2009 02:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-for-consecutive-numeric-characters-in-a-string/m-p/62841#M13669</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-18T02:22:04Z</dc:date>
    </item>
  </channel>
</rss>

