BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AndreaVianello
Obsidian | Level 7

I have in Oracle    TabA and TabB

  sql in Oracle 


select *  from TabA
where (idp, keyJ) in (select distinct id, key from TabB where flag in ('C','D') ) ;

work fine.  

in SAS 

 

libname ora oracle user="***" password="****" path="****";  

/** connection is ok !!**/


proc sql;
create table TabC as
select *  from   ora.TabA

  where (idp, keyJ) in (select distinct id, key from  ora.TabB where flag in ('C','D') ) ;
quit;


write ERROR 79-322: Expecting a (.  

  Why ? 


thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
where (idp, keyJ) in (select distinct id, key from ora.TabB where flag in ('C','D') ) ;

This is not valid SAS SQL, only Oracle so you need to convert that portion to a join.

View solution in original post

4 REPLIES 4
jimbarbour
Meteorite | Level 14

You need to use an explicit pass through type query.  Otherwise, you must use SAS syntax, which you don't want.

 

It would look something like this:

	PROC	SQL;
		CONNECT	TO	Oracle	AS	Cnx	("&Connection_Parameters");

		CREATE	TABLE	WORK.MyTable	AS
			SELECT	*	FROM	CONNECTION	TO	Cnx
				(SELECT	*	FROM	&Schema..&Table
				WHERE	&Where
							);

		DISCONNECT	FROM	Cnx;
	QUIT;

 

In your specific case, it might look something like the below.  I'm assuming that you have the Oracle driver and SAS Access for Oracle product installed.  ODBC would be another way to connect.

	PROC	SQL;
		CONNECT	TO	Oracle	AS	Ora	(user="***" password="****" path="****");

		CREATE	TABLE	WORK.MyTable	AS
			SELECT	*	FROM	CONNECTION	TO	Ora
				(select *  from TabA
					where (idp, keyJ) in (select distinct id, key from TabB where flag in ('C','D')) );

		DISCONNECT	FROM	Ora;
	QUIT;

Jim

Reeza
Super User
where (idp, keyJ) in (select distinct id, key from ora.TabB where flag in ('C','D') ) ;

This is not valid SAS SQL, only Oracle so you need to convert that portion to a join.
AndreaVianello
Obsidian | Level 7
thank you !

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1593 views
  • 0 likes
  • 3 in conversation