<?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 How to parse the first consecutive numeric substring from a character? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-parse-the-first-consecutive-numeric-substring-from-a/m-p/844273#M82274</link>
    <description>&lt;P&gt;I want to extract the first numeric substring that shows up in a character variable. For example,&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
 	infile datalines delimiter = "," missover;
	input string $;
	datalines;
	abc 12345 &amp;amp;*ag21
	bld#5432 
	8642 12 asd
	kmdsf 657
run;

data want;
	length string $30. substring $30.;
	infile datalines dsd dlm='|' truncover ;
	input string $ substring $;
	datalines;
	abc 12345 &amp;amp;*ag21|12345
	bld#5432|5432
	8642 12 asd|8642
	kmdsf 657|657
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there a good way to do this in a data step?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Nov 2022 04:32:46 GMT</pubDate>
    <dc:creator>xyxu</dc:creator>
    <dc:date>2022-11-15T04:32:46Z</dc:date>
    <item>
      <title>How to parse the first consecutive numeric substring from a character?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-parse-the-first-consecutive-numeric-substring-from-a/m-p/844273#M82274</link>
      <description>&lt;P&gt;I want to extract the first numeric substring that shows up in a character variable. For example,&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
 	infile datalines delimiter = "," missover;
	input string $;
	datalines;
	abc 12345 &amp;amp;*ag21
	bld#5432 
	8642 12 asd
	kmdsf 657
run;

data want;
	length string $30. substring $30.;
	infile datalines dsd dlm='|' truncover ;
	input string $ substring $;
	datalines;
	abc 12345 &amp;amp;*ag21|12345
	bld#5432|5432
	8642 12 asd|8642
	kmdsf 657|657
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there a good way to do this in a data step?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 04:32:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-parse-the-first-consecutive-numeric-substring-from-a/m-p/844273#M82274</guid>
      <dc:creator>xyxu</dc:creator>
      <dc:date>2022-11-15T04:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse the first consecutive numeric substring from a character?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-parse-the-first-consecutive-numeric-substring-from-a/m-p/844368#M82277</link>
      <description>&lt;P&gt;You want to look at&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n1lru1b4uoogqvn1ig446q4c6muu.htm#p0oyy68zywo4w4n17byrp0veqm3e" target="_self"&gt;PRXPOSN Function - Extracting First and Last Names&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 	infile datalines delimiter = "," missover;
	input string $;
	datalines;
	abc 12345 &amp;amp;*ag21
	bld#5432 
	8642 12 asd
	kmdsf 657
run;

data results ;
	length string $30. substring $30.;
	infile datalines dsd dlm='|' truncover ;
	input string $ substring $;
	datalines;
	abc 12345 &amp;amp;*ag21|12345
	bld#5432|5432
	8642 12 asd|8642
	kmdsf 657|657
run;

data wamt ;
	retain patternID ;
	set have ;
	if _n_=1 then do ;
		patternID=prxparse('/([0-9]+)/') ;
	end ;
	found=prxmatch(patternID,string) ;
	want=prxposn(patternID,1,string) ;
	put string= found= want= ;

run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Nov 2022 13:34:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-parse-the-first-consecutive-numeric-substring-from-a/m-p/844368#M82277</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2022-11-15T13:34:19Z</dc:date>
    </item>
  </channel>
</rss>

