<?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 the middle numbers from an Alphanumeric string of varying length in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-the-middle-numbers-from-an-Alphanumeric-string-of/m-p/810733#M319734</link>
    <description>&lt;P&gt;This assumes the substring you want always begins with the first digit in the string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards;
input x $ string &amp;amp;:$50.;
cards;
1)  SC_NATLTAP_P_617686046__0520 
2)  NC_OPTUM PARTD_R_220335038421000999P__0910
;
run;

data want;
set have;
start = anydigit(string);  * find location of first digit;
num = scan(substr(string, start), 1, '_');  * extract substring that end with '_'; 
drop x start;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Apr 2022 20:55:20 GMT</pubDate>
    <dc:creator>average_joe</dc:creator>
    <dc:date>2022-04-29T20:55:20Z</dc:date>
    <item>
      <title>Extract the middle numbers from an Alphanumeric string of varying length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-the-middle-numbers-from-an-Alphanumeric-string-of/m-p/810724#M319728</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I'm needing to extract the middle numbers from an alphanumeric string that can have varying lengths.&lt;/P&gt;
&lt;P&gt;This an example of the alphanumeric strings:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; Have:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1)&amp;nbsp; SC_NATLTAP_P_617686046__0520&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2)&amp;nbsp;&amp;nbsp;NC_OPTUM PARTD_R_220335038421000999P__0910&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1)&amp;nbsp; 617686046&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2)&amp;nbsp;&amp;nbsp;220335038421000999P&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've used Compress, but still leaves the last 4 digits, which I don't need.&lt;/P&gt;
&lt;P&gt;ID = Compress(clm_nb,"_","A");&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 18:51:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-the-middle-numbers-from-an-Alphanumeric-string-of/m-p/810724#M319728</guid>
      <dc:creator>suncawy</dc:creator>
      <dc:date>2022-04-29T18:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: Extract the middle numbers from an Alphanumeric string of varying length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-the-middle-numbers-from-an-Alphanumeric-string-of/m-p/810733#M319734</link>
      <description>&lt;P&gt;This assumes the substring you want always begins with the first digit in the string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards;
input x $ string &amp;amp;:$50.;
cards;
1)  SC_NATLTAP_P_617686046__0520 
2)  NC_OPTUM PARTD_R_220335038421000999P__0910
;
run;

data want;
set have;
start = anydigit(string);  * find location of first digit;
num = scan(substr(string, start), 1, '_');  * extract substring that end with '_'; 
drop x start;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 20:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-the-middle-numbers-from-an-Alphanumeric-string-of/m-p/810733#M319734</guid>
      <dc:creator>average_joe</dc:creator>
      <dc:date>2022-04-29T20:55:20Z</dc:date>
    </item>
  </channel>
</rss>

