<?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: Extract a number somewhere in a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-number-somewhere-in-a-string/m-p/331606#M74552</link>
    <description>&lt;P&gt;Does your data have date values along with the number string you are searching for?&lt;/P&gt;
&lt;P&gt;How about identifiers that may include digits such as Highway 66, addresses, telephone numbers or similar?&lt;/P&gt;</description>
    <pubDate>Fri, 10 Feb 2017 17:45:45 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-02-10T17:45:45Z</dc:date>
    <item>
      <title>Extract a number somewhere in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-number-somewhere-in-a-string/m-p/331597#M74547</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a quite long string, with somewhere inside the string: a number, composed by a various number of digits.&lt;/P&gt;&lt;P&gt;I need to extract the complete number.&lt;/P&gt;&lt;P&gt;I am sure that on the right there is at least one character, on the left too.&lt;/P&gt;&lt;P&gt;All characters apart from the number are not digits.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know how I can do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 17:00:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-a-number-somewhere-in-a-string/m-p/331597#M74547</guid>
      <dc:creator>fabdu92</dc:creator>
      <dc:date>2017-02-10T17:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a number somewhere in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-number-somewhere-in-a-string/m-p/331600#M74549</link>
      <description>&lt;P&gt;Can you show us your data or if not replicate a dummy of it ?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 17:24:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-a-number-somewhere-in-a-string/m-p/331600#M74549</guid>
      <dc:creator>anoopmohandas7</dc:creator>
      <dc:date>2017-02-10T17:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a number somewhere in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-number-somewhere-in-a-string/m-p/331604#M74551</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;Many different methods. I find prxchange most useful for that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; length&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; num $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;str = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'ssfdfsf56789qeqeqd'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;num = prxchange(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'s/(\D*)(\d*)(\D*)/$2/'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;,str);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; num=;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 17:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-a-number-somewhere-in-a-string/m-p/331604#M74551</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2017-02-10T17:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a number somewhere in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-number-somewhere-in-a-string/m-p/331606#M74552</link>
      <description>&lt;P&gt;Does your data have date values along with the number string you are searching for?&lt;/P&gt;
&lt;P&gt;How about identifiers that may include digits such as Highway 66, addresses, telephone numbers or similar?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 17:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-a-number-somewhere-in-a-string/m-p/331606#M74552</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-10T17:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a number somewhere in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-number-somewhere-in-a-string/m-p/331621#M74554</link>
      <description>&lt;P&gt;setting assurances for matching the whole string would be better, on the off change more that one string of numbers happens to occur in a row of the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;num = prxchange('s/^\D+(\d+)\D+$/$1',1,str);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;also, since OP states there is definitely at least one char to left and right, can use + instead of * to further validate expected input.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 18:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-a-number-somewhere-in-a-string/m-p/331621#M74554</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2017-02-10T18:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a number somewhere in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-a-number-somewhere-in-a-string/m-p/331629#M74558</link>
      <description>&lt;P&gt;Since you simply want all the digits, a suitably simple approach would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;num = compress(long_string, , 'kd');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;k = keep&lt;/P&gt;
&lt;P&gt;d = digits&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 18:46:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-a-number-somewhere-in-a-string/m-p/331629#M74558</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-02-10T18:46:39Z</dc:date>
    </item>
  </channel>
</rss>

