<?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 extract the numbers from the text? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-numbers-from-the-text/m-p/688510#M209178</link>
    <description>&lt;P&gt;Good morning,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to extract the numbers from the sample dataset 'Have'.&amp;nbsp;&amp;nbsp; I list the result I would like to get in the 'Want' dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data Have;
      infile datalines delimiter='#';
  input Comments : $200.  ;
datalines;
	UGESTAGE=34 5/7 WKS #
	UGESTAGE=35WKS #
	UGESTAGE=33.4 WKS #
	UGESTAGE= 24 WKS
;
run;

data Want;
      infile datalines delimiter='/';
  input UGESTAGE  ;
datalines;
	34 /
	35 /
	33 /
	24
;
run;&lt;/PRE&gt;</description>
    <pubDate>Fri, 02 Oct 2020 13:47:44 GMT</pubDate>
    <dc:creator>ybz12003</dc:creator>
    <dc:date>2020-10-02T13:47:44Z</dc:date>
    <item>
      <title>How to extract the numbers from the text?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-numbers-from-the-text/m-p/688510#M209178</link>
      <description>&lt;P&gt;Good morning,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to extract the numbers from the sample dataset 'Have'.&amp;nbsp;&amp;nbsp; I list the result I would like to get in the 'Want' dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data Have;
      infile datalines delimiter='#';
  input Comments : $200.  ;
datalines;
	UGESTAGE=34 5/7 WKS #
	UGESTAGE=35WKS #
	UGESTAGE=33.4 WKS #
	UGESTAGE= 24 WKS
;
run;

data Want;
      infile datalines delimiter='/';
  input UGESTAGE  ;
datalines;
	34 /
	35 /
	33 /
	24
;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Oct 2020 13:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-numbers-from-the-text/m-p/688510#M209178</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-10-02T13:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the numbers from the text?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-numbers-from-the-text/m-p/688511#M209179</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want=input(prxchange("s/^[^\d]*(\d+).*$/$1/",1,Comments), best.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Oct 2020 13:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-numbers-from-the-text/m-p/688511#M209179</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2020-10-02T13:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the numbers from the text?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-numbers-from-the-text/m-p/688515#M209182</link>
      <description>Super!  &lt;BR /&gt;&lt;BR /&gt;But what is '^[^\d]*(\d+).*$/$1'?&lt;BR /&gt;&lt;BR /&gt;And what is '1' in front of the 'Comments'?</description>
      <pubDate>Fri, 02 Oct 2020 14:11:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-numbers-from-the-text/m-p/688515#M209182</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-10-02T14:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the numbers from the text?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-numbers-from-the-text/m-p/688519#M209184</link>
      <description>It is a perl regular expression (regexp).&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://perldoc.perl.org/perlre" target="_blank"&gt;https://perldoc.perl.org/perlre&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;^ : beginning of the string&lt;BR /&gt;$ : end of the string&lt;BR /&gt;\d a digit&lt;BR /&gt;[^\d] any non digit&lt;BR /&gt;[^\d]* any sequence of non-digits&lt;BR /&gt;\d+ any non empty sequence of digits&lt;BR /&gt;(\d+)  =&amp;gt; the matching string can be referred to in the replace string with $1 ($2, $3, ... if there are other (...) in the regexp)&lt;BR /&gt;.* any sequence of characters&lt;BR /&gt;&lt;BR /&gt;So the command searches for a string begining with any sequence of non digits followed by a sequence&lt;BR /&gt;of digits (which is given the alias "$1") followed by any sequence of characters.&lt;BR /&gt;The input string is replaced by the matching sequence of digits.&lt;BR /&gt;&lt;BR /&gt;prxchange SAS function allows to use perl regular expressions to search/replace elements in a string.&lt;BR /&gt;&lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n0r8h2fa8djqf1n1cnenrvm573br.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n0r8h2fa8djqf1n1cnenrvm573br.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Oct 2020 14:29:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-numbers-from-the-text/m-p/688519#M209184</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2020-10-02T14:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the numbers from the text?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-numbers-from-the-text/m-p/688576#M209201</link>
      <description>Thank you!</description>
      <pubDate>Fri, 02 Oct 2020 17:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-numbers-from-the-text/m-p/688576#M209201</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-10-02T17:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the numbers from the text?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-numbers-from-the-text/m-p/688680#M209254</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
      infile datalines delimiter='#';
  input Comments : $200.  ;
datalines;
	UGESTAGE=34 5/7 WKS #
	UGESTAGE=35WKS #
	UGESTAGE=33.4 WKS #
	UGESTAGE= 24 WKS
;
run;

data Want;
 set have;
 want=scan(comments,1,,'kd');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Oct 2020 12:04:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-numbers-from-the-text/m-p/688680#M209254</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-10-03T12:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the numbers from the text?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-numbers-from-the-text/m-p/688865#M209361</link>
      <description>&lt;P&gt;Somehow, I used PERI code is not working properly.&amp;nbsp;&amp;nbsp; I changed to use Ksharp's code, it works fine.&amp;nbsp;&amp;nbsp; Thanks much!&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2020 12:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-the-numbers-from-the-text/m-p/688865#M209361</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-10-05T12:57:42Z</dc:date>
    </item>
  </channel>
</rss>

