BookmarkSubscribeRSS Feed
RobertNYC
Obsidian | Level 7

I’m trying to translate an oracle query to proc sql.  I am still pull through a connection to an oracle environment but I have to use proc sql in SAS.  There is a section in the query I am having trouble translation. 

 

I don't think I can use the  Instr  and NVL within  a proc sql statement.

 

Any assistance will be greatly appreciated.

 

proc sql;
connect to oracle (user=polodm password=polodm path='K6PPOLDM');
create table CUSTOMER_TRANS as
select * 
from connection to oracle (
select distinct 
cu.mstr_customer_id, 
t.customer_id
from mbs.sas_transaction_vw t inner join mbs.sas_customer_vw cu
on cu.customer_id = t.customer_id
where t.transaction_date >= '01AUG2014'  and t.transaction_date <= '30AUG2014' 
and t.transaction_type = 1
and t.business_unit IN (1,3)
and not in (
select customer_id
from mbs.sas_customer_bu_vw where business_unit = 3 
and Instr(substr(rtm_bulk_flags,1,3),'Y') > 0
or Instr(NVL(suppress_reasons, ' '),'E') > 0 /*Employees*/
or Instr(NVL(suppress_reasons, ' '),'F') > 0 /*Fraud*/)
and business_unit in (1,3)
and customer_id = t.customer_id)
disconnect from oracle;quit; 
4 REPLIES 4
ballardw
Super User

For those of use that do not use Oracle you could describe what INSTR and NVL do.

ChrisHemedinger
Community Manager

I think you might just want the FIND function (if working with SAS data) or the INDEXC function is an old-school method that could work too.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
SASKiwi
PROC Star

So you have a SAS SQL passthru query that works fine on Oracle and you HAVE to translate it into SAS SQL. Why? 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1486 views
  • 1 like
  • 5 in conversation