<?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: Combining two Arrays which use regular expressions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combining-two-Arrays-which-use-regular-expressions/m-p/230662#M41868</link>
    <description>&lt;P&gt;I like to use CALL PRXNEXT() for this kind of extraction. Here I also use look behind buffers (?&amp;lt;=...)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;

url_id = 1;
url = "The productId=123 and the categoryId=5555 or categoryId=6666";

if not catID then 
    catID + prxParse("/(?&amp;lt;=categoryId=)(\d+)/");
if not proID then 
    proID + prxParse("/(?&amp;lt;=productId=)(\d+)/");

type = "category";
start = 1; stop = length(url);
call prxnext(catID, start, stop, url, pos, len);
do while (pos&amp;gt; 0);
    category_id = input(substr(url, pos, len), best32.);
    output;
    call prxnext(catID, start, stop, url, pos, len);
    end;

type = "product";
start = 1; stop = length(url);
call prxnext(proID, start, stop, url, pos, len);
do while (pos&amp;gt; 0);
    category_id = input(substr(url, pos, len), best32.);
    output;
    call prxnext(proID, start, stop, url, pos, len);
    end;

keep url_Id type category_id;
run;

proc print data=test noobs; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Oct 2015 18:22:36 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2015-10-20T18:22:36Z</dc:date>
    <item>
      <title>Combining two Arrays which use regular expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-two-Arrays-which-use-regular-expressions/m-p/230637#M41852</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi all. I have two arrays I’m trying to combine.&amp;nbsp; They both use regular expressions. One is looking for all the digits after categoryId= and one is looking for all the digits after productId=. I want to combine them into one so the array looks for either &amp;nbsp;categoryId= or productId= &amp;nbsp;so I don't have to use two data sets. I’m having trouble getting the regular expression syntax correct.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Camp1;
set Campaigns;
array url_array(*) $ url_:;
do i=1 to dim (url_array) ;
category_Id=input(prxchange('s/.+&lt;STRONG&gt;categoryId=&lt;/STRONG&gt;(\d+).+/$1/o',-1,URL_array(i)), 12.);
output;
end;
drop i;run;&lt;BR /&gt;&lt;BR /&gt;
data Camp2;
set Campaigns;
array url_array(*) $ url_:;
do i=1 to dim (url_array) ;
category_Id=input(prxchange('s/.+&lt;STRONG&gt;productId=&lt;/STRONG&gt;(\d+).+/$1/o',-1,URL_array(i)), 12.);
output;
end;
drop i;run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2015 19:34:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-two-Arrays-which-use-regular-expressions/m-p/230637#M41852</guid>
      <dc:creator>Mgarret</dc:creator>
      <dc:date>2015-10-19T19:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Combining two Arrays which use regular expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-two-Arrays-which-use-regular-expressions/m-p/230660#M41866</link>
      <description>&lt;P&gt;Please try this untested code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;data Camp1;
set Campaigns;
array url_array(*) $ url_:;
do i=1 to dim (url_array) ;
if prxmatch('m/.+categoryId=(\d+).+/',URL_array(i)) &amp;gt;0 then category_Id=input(prxchange('s/.+categoryId=(\d+).+/$1/o',-1,URL_array(i)), 12.);
else if prxmatch('m/.+productId=(\d+).+/',URL_array(i)) &amp;gt;0 then category_Id=input(prxchange('s/.+productId=(\d+).+/$1/o',-1,URL_array(i)), 12.);
output;
end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Oct 2015 01:32:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-two-Arrays-which-use-regular-expressions/m-p/230660#M41866</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-10-20T01:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: Combining two Arrays which use regular expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-two-Arrays-which-use-regular-expressions/m-p/230662#M41868</link>
      <description>&lt;P&gt;I like to use CALL PRXNEXT() for this kind of extraction. Here I also use look behind buffers (?&amp;lt;=...)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;

url_id = 1;
url = "The productId=123 and the categoryId=5555 or categoryId=6666";

if not catID then 
    catID + prxParse("/(?&amp;lt;=categoryId=)(\d+)/");
if not proID then 
    proID + prxParse("/(?&amp;lt;=productId=)(\d+)/");

type = "category";
start = 1; stop = length(url);
call prxnext(catID, start, stop, url, pos, len);
do while (pos&amp;gt; 0);
    category_id = input(substr(url, pos, len), best32.);
    output;
    call prxnext(catID, start, stop, url, pos, len);
    end;

type = "product";
start = 1; stop = length(url);
call prxnext(proID, start, stop, url, pos, len);
do while (pos&amp;gt; 0);
    category_id = input(substr(url, pos, len), best32.);
    output;
    call prxnext(proID, start, stop, url, pos, len);
    end;

keep url_Id type category_id;
run;

proc print data=test noobs; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2015 18:22:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-two-Arrays-which-use-regular-expressions/m-p/230662#M41868</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-10-20T18:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Combining two Arrays which use regular expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-two-Arrays-which-use-regular-expressions/m-p/230669#M41874</link>
      <description>&lt;P&gt;Assuming "productid" and "categoryid" are mutually exclusive in your strings then the following could work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Camp1;
  set Campaigns;
  array url_array(*) $ url_:;
  do i=1 to dim (url_array);
    category_Id=input(prxchange('s/.+&lt;SPAN&gt;[[:^alnum:]]&lt;/SPAN&gt;(categoryId=|productId=)(\d+).+/$2/oi',1,URL_array(i)), 12.);
    output;
  end;
  drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Oct 2015 08:51:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-two-Arrays-which-use-regular-expressions/m-p/230669#M41874</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-10-20T08:51:10Z</dc:date>
    </item>
  </channel>
</rss>

