BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ammarhm
Lapis Lazuli | Level 10

Hi everyone

I am using the following code to connect ot oracle:

proc sql;
connect using datax as oracle;
create table combined_user as
select 
	*
	
from connection to oracle
	(
	select distinct 
		*
	from datax.dbo.process a left join datax.dbo.users b 
	  on a.id=b.id and a.location=b.location
	);
quit;

This is working fine without issues.

 

Due to problems with id coding, I needed to remove some punctuations in the column id from the first table. i tried the following 

 



proc sql;
connect using datax as oracle;
create table combined_user as
select 
	*
	
from connection to oracle
	(
	select distinct 
		*
	from datax.dbo.process a left join datax.dbo.users b 
	  on compress(a.id,,'p')=b.id and a.location=b.location
	);
quit;

which generated an error, possibly because oracle does not understand the command compress. 

Any suggestions on how to solve this? I tried reg_replace but with no luck

Another question, is there anything in oracle that can do something similar to matching by "like"?

 

	(
	select distinct 
		*
	from datax.dbo.process a left join datax.dbo.users b 
	  on compress(a.id,,'p') like b.id and a.location=b.location
	);
quit;

Kind regards

Am

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

You can't use SAS function in an Oracle query, just like you can't use Oracle functions in a SAS query.

 

 

replace(translate(ID, '.,-:+*/;', '#'), '#', '')

 

does what you want.

View solution in original post

5 REPLIES 5
r_behata
Barite | Level 11

Your question has the answer in it. You cannot use the sas functions inside the SQL Pass-thru query.

 

You should perhaps use the Oracle equivalent for compress which is TRIM , which removes the leading and trailing blanks and you can also add the punctuation to the list of characters to the TRIM function which you are trying to remove in the query.

 

 

ChrisNZ
Tourmaline | Level 20

You can't use SAS function in an Oracle query, just like you can't use Oracle functions in a SAS query.

 

 

replace(translate(ID, '.,-:+*/;', '#'), '#', '')

 

does what you want.

ChrisNZ
Tourmaline | Level 20

 

regexp_replace(ID, '[-.,:+*/;]') 

works too.

 

ChrisNZ
Tourmaline | Level 20

proc sql;
connect using datax as oracle;
create table combined_user as
select *
from connection to oracle
(
select distinct *
from datax.dbo.process a left join datax.dbo.users b
on compress(a.id,,'p')=b.id and a.location=b.location
)
order by 1;
quit;

 

Just a reminder:

The code in blue runs in SAS and requires SAS syntax.

The code in red runs in Oracle and requires Oracle syntax.

 

ammarhm
Lapis Lazuli | Level 10

Thanks all,

Any suggestions about using LIKE with wilde card % in Oracle?

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 1522 views
  • 1 like
  • 3 in conversation