<?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 certain numeric from a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-certain-numeric-from-a-string/m-p/612195#M178571</link>
    <description>&lt;P&gt;There are a few cases start with a number&lt;/P&gt;&lt;P&gt;448 insG&lt;BR /&gt;639+5G&amp;gt;A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want:&lt;/P&gt;&lt;P&gt;448&lt;/P&gt;&lt;P&gt;639&lt;/P&gt;</description>
    <pubDate>Mon, 16 Dec 2019 19:54:51 GMT</pubDate>
    <dc:creator>achen</dc:creator>
    <dc:date>2019-12-16T19:54:51Z</dc:date>
    <item>
      <title>Extract certain numeric from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-certain-numeric-from-a-string/m-p/612182#M178561</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Here is my data&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;E90K&lt;BR /&gt;G1006AfsX51&lt;BR /&gt;W1001X&lt;BR /&gt;R1014X&lt;BR /&gt;D102A&lt;BR /&gt;G1036D&lt;BR /&gt;R1035G fsX22&amp;nbsp;&lt;BR /&gt;R1035fsX1056&lt;/P&gt;&lt;P&gt;C52AfsX8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I want&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;90&lt;/P&gt;&lt;P&gt;1006&lt;/P&gt;&lt;P&gt;1001&lt;/P&gt;&lt;P&gt;1014&lt;/P&gt;&lt;P&gt;102&lt;/P&gt;&lt;P&gt;1036&lt;/P&gt;&lt;P&gt;1035&lt;/P&gt;&lt;P&gt;1035&lt;/P&gt;&lt;P&gt;52&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 19:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-certain-numeric-from-a-string/m-p/612182#M178561</guid>
      <dc:creator>achen</dc:creator>
      <dc:date>2019-12-16T19:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Extract certain numeric from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-certain-numeric-from-a-string/m-p/612188#M178565</link>
      <description>&lt;P&gt;So, does the numeric always begin in the second character? If so&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    string=substr(string,2); /* Throw out first character, we don't need it */
    numeric=input(substr(string,1,notdigit(string)-1),10.0);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Dec 2019 19:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-certain-numeric-from-a-string/m-p/612188#M178565</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-12-16T19:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Extract certain numeric from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-certain-numeric-from-a-string/m-p/612191#M178568</link>
      <description>&lt;P&gt;One simple way is to use SCAN() and tell that everything except digits are the delimiter characters.&lt;/P&gt;
&lt;P&gt;So to get it as another character variable use something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  numb = scan(string,1,compress(string,,'d'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or add an INPUT() function call to convert it to an actual number.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  numb = input(scan(string,1,compress(string,,'d')),??32.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    string          numb

  1    E90K              90
  2    G1006AfsX51     1006
  3    W1001X          1001
  4    R1014X          1014
  5    D102A            102
  6    G1036D          1036
  7    R1035G fsX22    1035
  8    R1035fsX1056    1035
  9                       .
 10    C52AfsX8          52&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Dec 2019 19:50:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-certain-numeric-from-a-string/m-p/612191#M178568</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-16T19:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Extract certain numeric from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-certain-numeric-from-a-string/m-p/612195#M178571</link>
      <description>&lt;P&gt;There are a few cases start with a number&lt;/P&gt;&lt;P&gt;448 insG&lt;BR /&gt;639+5G&amp;gt;A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want:&lt;/P&gt;&lt;P&gt;448&lt;/P&gt;&lt;P&gt;639&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 19:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-certain-numeric-from-a-string/m-p/612195#M178571</guid>
      <dc:creator>achen</dc:creator>
      <dc:date>2019-12-16T19:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: Extract certain numeric from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-certain-numeric-from-a-string/m-p/612196#M178572</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/303805"&gt;@achen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;There are a few cases start with a number&lt;/P&gt;
&lt;P&gt;448 insG&lt;BR /&gt;639+5G&amp;gt;A&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want:&lt;/P&gt;
&lt;P&gt;448&lt;/P&gt;
&lt;P&gt;639&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are there any other cases we need to know about?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 19:58:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-certain-numeric-from-a-string/m-p/612196#M178572</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-12-16T19:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Extract certain numeric from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-certain-numeric-from-a-string/m-p/612197#M178573</link>
      <description>&lt;P&gt;Tom, thank you and it works great!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 20:01:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-certain-numeric-from-a-string/m-p/612197#M178573</guid>
      <dc:creator>achen</dc:creator>
      <dc:date>2019-12-16T20:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Extract certain numeric from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-certain-numeric-from-a-string/m-p/612369#M178681</link>
      <description>&lt;P&gt;Tom,&lt;/P&gt;
&lt;P&gt;scan() has built-in modified option for this kind of situation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input string $20.;
cards;
E90K
G1006AfsX51
W1001X
R1014X
D102A
G1036D
R1035G fsX22 
R1035fsX1056
C52AfsX8
;
data want ;
  set have ;
  numb = scan(string,1,,'kd');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Dec 2019 12:05:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-certain-numeric-from-a-string/m-p/612369#M178681</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-12-17T12:05:17Z</dc:date>
    </item>
  </channel>
</rss>

