<?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 Proc sql in Oracle:  Using Regular Expressions instead of LIKE Function criteria in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-in-Oracle-Using-Regular-Expressions-instead-of-LIKE/m-p/331261#M62704</link>
    <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Below is a proc sql Oracle &amp;nbsp;query I’ve written which pulls various promotion history based on elements in a string var.&amp;nbsp;&amp;nbsp; I would like very much to use &lt;STRONG&gt;regular expressions&lt;/STRONG&gt; as opposed to a bunch of &lt;STRONG&gt;LIKE&lt;/STRONG&gt; functions. I’m having trouble figuring out how to do this in the Oracle environment. The section of the query I would like to modify using regular expressions is this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and t1.segment_key not like '%N'&lt;/P&gt;
&lt;P&gt;and t1.segment_key not like '%C'&lt;/P&gt;
&lt;P&gt;and t1.segment_key not like 'CNM'&lt;/P&gt;
&lt;P&gt;and (t2.client_promo_id like 'PD%'&lt;/P&gt;
&lt;P&gt;or t2.client_promo_id like 'FD%'&lt;/P&gt;
&lt;P&gt;or t2.client_promo_id like 'RD%'&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or t2.client_promo_id like 'PE%'&lt;/P&gt;
&lt;P&gt;or t2.client_promo_id like 'FE%'&lt;/P&gt;
&lt;P&gt;or t2.client_promo_id like 'RE%'&lt;/P&gt;
&lt;P&gt;or t2.client_promo_id like 'RLS%'&lt;/P&gt;
&lt;P&gt;or t2.promotion_title like '%RL%')&lt;/P&gt;
&lt;P&gt;and t2.promotion_title not like '%RGB%'&lt;/P&gt;
&lt;P&gt;and t2.promotion_title not like '%Rugby%'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any assistance will be greatly appreciated. Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Full query:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
connect to oracle (user=xxx path='xxx');
create table Want as
select  * from connection to oracle (
select    
t1.customer_id, 
count(distinct case when t1.promotion_type=1 then t1.promotion_id end) as dm_ttl,
count(distinct case when t1.promotion_type=2 then t1.promotion_id end) as email_ttl
from sas_promo_history_vw t1 join sas_promotion_vw t2       
 on  t1.promotion_id=t2.promotion_id
where t1.promotion_type in (1,2)
and t2.in_home_date between &amp;amp;start_date. and &amp;amp;End_date.
&lt;STRONG&gt;and t1.segment_key not like '%N' 
and t1.segment_key not like '%C' 
and t1.segment_key not like 'CNM' 
and (t2.client_promo_id like 'PD%' 
or t2.client_promo_id like 'FD%' 
or t2.client_promo_id like 'RD%'  
or t2.client_promo_id like 'PE%' 
or t2.client_promo_id like 'FE%' 
or t2.client_promo_id like 'RE%'
or t2.client_promo_id like 'RLS%'
or t2.promotion_title like '%RL%')&lt;/STRONG&gt;
&lt;STRONG&gt;and t2.promotion_title not like '%RGB%' 
and t2.promotion_title not like '%Rugby%'&lt;/STRONG&gt;
group by t1.customer_id);
disconnect from oracle;quit;
&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 Feb 2017 17:53:56 GMT</pubDate>
    <dc:creator>RobertNYC</dc:creator>
    <dc:date>2017-02-09T17:53:56Z</dc:date>
    <item>
      <title>Proc sql in Oracle:  Using Regular Expressions instead of LIKE Function criteria</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-in-Oracle-Using-Regular-Expressions-instead-of-LIKE/m-p/331261#M62704</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Below is a proc sql Oracle &amp;nbsp;query I’ve written which pulls various promotion history based on elements in a string var.&amp;nbsp;&amp;nbsp; I would like very much to use &lt;STRONG&gt;regular expressions&lt;/STRONG&gt; as opposed to a bunch of &lt;STRONG&gt;LIKE&lt;/STRONG&gt; functions. I’m having trouble figuring out how to do this in the Oracle environment. The section of the query I would like to modify using regular expressions is this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and t1.segment_key not like '%N'&lt;/P&gt;
&lt;P&gt;and t1.segment_key not like '%C'&lt;/P&gt;
&lt;P&gt;and t1.segment_key not like 'CNM'&lt;/P&gt;
&lt;P&gt;and (t2.client_promo_id like 'PD%'&lt;/P&gt;
&lt;P&gt;or t2.client_promo_id like 'FD%'&lt;/P&gt;
&lt;P&gt;or t2.client_promo_id like 'RD%'&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or t2.client_promo_id like 'PE%'&lt;/P&gt;
&lt;P&gt;or t2.client_promo_id like 'FE%'&lt;/P&gt;
&lt;P&gt;or t2.client_promo_id like 'RE%'&lt;/P&gt;
&lt;P&gt;or t2.client_promo_id like 'RLS%'&lt;/P&gt;
&lt;P&gt;or t2.promotion_title like '%RL%')&lt;/P&gt;
&lt;P&gt;and t2.promotion_title not like '%RGB%'&lt;/P&gt;
&lt;P&gt;and t2.promotion_title not like '%Rugby%'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any assistance will be greatly appreciated. Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Full query:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
connect to oracle (user=xxx path='xxx');
create table Want as
select  * from connection to oracle (
select    
t1.customer_id, 
count(distinct case when t1.promotion_type=1 then t1.promotion_id end) as dm_ttl,
count(distinct case when t1.promotion_type=2 then t1.promotion_id end) as email_ttl
from sas_promo_history_vw t1 join sas_promotion_vw t2       
 on  t1.promotion_id=t2.promotion_id
where t1.promotion_type in (1,2)
and t2.in_home_date between &amp;amp;start_date. and &amp;amp;End_date.
&lt;STRONG&gt;and t1.segment_key not like '%N' 
and t1.segment_key not like '%C' 
and t1.segment_key not like 'CNM' 
and (t2.client_promo_id like 'PD%' 
or t2.client_promo_id like 'FD%' 
or t2.client_promo_id like 'RD%'  
or t2.client_promo_id like 'PE%' 
or t2.client_promo_id like 'FE%' 
or t2.client_promo_id like 'RE%'
or t2.client_promo_id like 'RLS%'
or t2.promotion_title like '%RL%')&lt;/STRONG&gt;
&lt;STRONG&gt;and t2.promotion_title not like '%RGB%' 
and t2.promotion_title not like '%Rugby%'&lt;/STRONG&gt;
group by t1.customer_id);
disconnect from oracle;quit;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Feb 2017 17:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-in-Oracle-Using-Regular-Expressions-instead-of-LIKE/m-p/331261#M62704</guid>
      <dc:creator>RobertNYC</dc:creator>
      <dc:date>2017-02-09T17:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql in Oracle:  Using Regular Expressions instead of LIKE Function criteria</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-in-Oracle-Using-Regular-Expressions-instead-of-LIKE/m-p/331265#M62705</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;...
and not regexp_like (t1.segment_key, '[NC]$')
and t1.segment_key != 'CNM'
and (
  regexp_like (t2.client_promo_id, '^([FR]D|[PFR]E|RLS)')
  or t2.promotion_title like '%RL%' )
and not regexp_like (t2.promotion_title,'(RGB|Rugby)')
...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Feb 2017 18:04:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-in-Oracle-Using-Regular-Expressions-instead-of-LIKE/m-p/331265#M62705</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2017-02-09T18:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql in Oracle:  Using Regular Expressions instead of LIKE Function criteria</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-in-Oracle-Using-Regular-Expressions-instead-of-LIKE/m-p/331504#M62742</link>
      <description>&lt;P&gt;The is beatiful! Thanks!!!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 13:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-in-Oracle-Using-Regular-Expressions-instead-of-LIKE/m-p/331504#M62742</guid>
      <dc:creator>RobertNYC</dc:creator>
      <dc:date>2017-02-10T13:49:59Z</dc:date>
    </item>
  </channel>
</rss>

