<?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: Extracting multiple matched pattern from dataset in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Extracting-multiple-matched-pattern-from-dataset/m-p/575122#M12799</link>
    <description>&lt;P&gt;May be try and change the second last parameter from 1 to -1 so that the RegEx gets applied as many times as possible.&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;dsdate&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;prxchange&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'s/.*(\d{2}(\s+|-)\w+(\s+|-)\d{2,4}).*/\1/'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; -&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; term&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively use&amp;nbsp;a RegEx to just match the date patterns in the string and then implement a loop to extract all matching occurrences within the string using call prxnext()&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n1obc9u7z3225mn1npwnassehff0.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://go.documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n1obc9u7z3225mn1npwnassehff0.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 20 Jul 2019 10:01:30 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-07-20T10:01:30Z</dc:date>
    <item>
      <title>Extracting multiple matched pattern from dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-multiple-matched-pattern-from-dataset/m-p/575113#M12794</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I want to extract all dates from&amp;nbsp; term variable:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data in term vriables is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Days of 08 April 19&lt;/P&gt;&lt;P&gt;count on 10 May 2019, 05 May&amp;nbsp; 2018, 08-Jan-2005&lt;/P&gt;&lt;P&gt;apply i.e.&amp;nbsp;08 April 19 and 10-Jan-2005&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want ro extract all dates from above variable, in one or multiple vriables using regex or perl regular expression&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the following program but I am geting only last date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cd.new;
    set cd.Date_ex;
    dsdate=prxchange('s/.*(\d{2}(\s+|-)\w+(\s+|-)\d{2,4}).*/\1/', 1, term);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;P&gt;08 April 19&lt;/P&gt;&lt;P&gt;08-Jan-2005&lt;/P&gt;&lt;P&gt;10-Jan-2005&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2019 08:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-multiple-matched-pattern-from-dataset/m-p/575113#M12794</guid>
      <dc:creator>surajmetha55</dc:creator>
      <dc:date>2019-07-20T08:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting multiple matched pattern from dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-multiple-matched-pattern-from-dataset/m-p/575122#M12799</link>
      <description>&lt;P&gt;May be try and change the second last parameter from 1 to -1 so that the RegEx gets applied as many times as possible.&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;dsdate&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;prxchange&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'s/.*(\d{2}(\s+|-)\w+(\s+|-)\d{2,4}).*/\1/'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; -&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; term&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively use&amp;nbsp;a RegEx to just match the date patterns in the string and then implement a loop to extract all matching occurrences within the string using call prxnext()&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n1obc9u7z3225mn1npwnassehff0.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://go.documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n1obc9u7z3225mn1npwnassehff0.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2019 10:01:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-multiple-matched-pattern-from-dataset/m-p/575122#M12799</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-07-20T10:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting multiple matched pattern from dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-multiple-matched-pattern-from-dataset/m-p/575136#M12810</link>
      <description>&lt;P&gt;It is really uneasy . This could give you a start.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input have $80.;
cards;
Days of 08 April 19
count on 10 May 2019, 05 May  2018, 08-Jan-2005
apply i.e. 08 April 19 and 10-Jan-2005
;

data want;
 set have;
 pid=prxparse('/\b\d+\W+[a-z]+\W+\d+\b/i');
 s=1;
 e=length(have);
 call prxnext(pid,s,e,have,p,l);
 do while(p&amp;gt;0);
  want=substr(have,p,l);
  output;
  call prxnext(pid,s,e,have,p,l);
 end;
drop s e p l pid;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Jul 2019 12:37:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-multiple-matched-pattern-from-dataset/m-p/575136#M12810</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-07-20T12:37:22Z</dc:date>
    </item>
  </channel>
</rss>

