<?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 only the numbers drom.alphanumerics using anyspace function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-only-the-numbers-drom-alphanumerics-using-anyspace/m-p/812123#M320408</link>
    <description>&lt;P&gt;Read your post multiple times, but still i am unable to grasp the rules that should be applied. So please explain them. Also explain, why you want to&amp;nbsp; use "anyspace".&lt;/P&gt;</description>
    <pubDate>Mon, 09 May 2022 10:56:19 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2022-05-09T10:56:19Z</dc:date>
    <item>
      <title>Extract only the numbers drom.alphanumerics using anyspace function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-only-the-numbers-drom-alphanumerics-using-anyspace/m-p/812117#M320406</link>
      <description>data ss;&lt;BR /&gt;input details$33.;&lt;BR /&gt;cards;&lt;BR /&gt;anam kusuma,3 id 2018, svcp&lt;BR /&gt;b bhavana, tirupati, 2018, 011&lt;BR /&gt;gracy, tirupati&lt;BR /&gt;indu priya, sas, 22, nellore&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Output is&lt;BR /&gt;3&lt;BR /&gt;2018&lt;BR /&gt;0&lt;BR /&gt;22</description>
      <pubDate>Mon, 09 May 2022 10:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-only-the-numbers-drom-alphanumerics-using-anyspace/m-p/812117#M320406</guid>
      <dc:creator>Sowmya12</dc:creator>
      <dc:date>2022-05-09T10:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Extract only the numbers drom.alphanumerics using anyspace function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-only-the-numbers-drom-alphanumerics-using-anyspace/m-p/812123#M320408</link>
      <description>&lt;P&gt;Read your post multiple times, but still i am unable to grasp the rules that should be applied. So please explain them. Also explain, why you want to&amp;nbsp; use "anyspace".&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 10:56:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-only-the-numbers-drom-alphanumerics-using-anyspace/m-p/812123#M320408</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-05-09T10:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Extract only the numbers drom.alphanumerics using anyspace function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-only-the-numbers-drom-alphanumerics-using-anyspace/m-p/812141#M320414</link>
      <description>&lt;P&gt;I think you want to do something like the example below, using &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1vz3ljudbd756n19502acxazevk.htm" target="_self"&gt;Regular Expressions&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What the example is doing is looking for a comma, followed by any number and combination of numerics and spaces, followed by another comma. It then extracts that value and converts it into a numeric.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Be warned this will also pick up values like ", 1 2 3 ," which will then probably return missing values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;What's not clear from your post is why the output has&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;3 for the first observation (maybe there's a typo and there's supposed to be a comma between 3 and id)&lt;/LI&gt;
&lt;LI&gt;Selects only 2018 for the second observation and not 011&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/* Using Perl Regular Expressions in the DATA Step */
/* https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1vz3ljudbd756n19502acxazevk.htm */ 

data ss;
input details $33.;
cards;
anam kusuma,3 id 2018, svcp
b bhavana, tirupati, 2018, 011
gracy, tirupati
indu priya, sas, 22, nellore
;
run;

data want ;	
	retain regExpID ;
	if _n_=1 then do ;
		regExpID=PRXPARSE('/,[0-9 ]*,/') ;
	end ;
	set ss ;
	prxmatch=prxmatch(regExpID,details) ;
	if pexmatch then do ;
		prxposn=prxposn(regExpID,0,details) ;
		number=inputn(substr(prxposn,2,length(prxposn)-2),"8.") ;
	end ;
	else
		number=0 ;
	put details= ;
	put prxmatch = ;
	put prxposn = ;
	put number= ;
	put "-------" ;

run ;	&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 09 May 2022 12:17:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-only-the-numbers-drom-alphanumerics-using-anyspace/m-p/812141#M320414</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2022-05-09T12:17:16Z</dc:date>
    </item>
  </channel>
</rss>

