BookmarkSubscribeRSS Feed
Rub_Saifi
Calcite | Level 5

Hi experts,

I am facing an error in SAS Viya.

Error -  SAS FEDSQL doesn't supports Subquery in its Syntax. While using subquery in the code its throwing error.As i want to use in Fedsql itself, I can't use this code in Proc Sql as I'm fetching the data from database.

How we can resolve it. Can you please help me out?

 

Code -:

 

Proc Fedsql Mysession = Sessref;

create table casuser.table {options replace = true compress - true} as

select
htd.TRAN_DATE,htd.tran_amt,htd.tran_id,decode(htd.part_tran_type,'C','CREDIT','DEBIT') part_tran_type,gam.acid as gamacid,htd.acid as htdacid,
(select foracid from tbaadm.gam@finlink where acid=htd.acid)account
from tbaadm.htd@finlink,tbaadm.gam@finlink
where gam.foracid IN ('0582955100398')
and acct_cls_flg='N'
and entity_cre_flg='Y'
and htd.pstd_flg='Y'
and htd.del_flg='N'
and htd.tran_date BETWEEN '23-Mar-2023' AND '23-Mar-2023'
and (tran_id,tran_date) in (select tran_id,tran_date from tbaadm.htd@finlink where htd.acid=gam.acid);

quit;

3 REPLIES 3
LinusH
Tourmaline | Level 20

Hi,

I'm a bit confused since FedSQL should support sub-queries.

https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.3/casfedsql/p1ucns3lrhzhamn1k6fw6vhzhzam.htm

 

Can you post the complete log?

 

And when you mention database, you refer to CAS, right?

Since if your data is in an external DB Proc SQL works.

Data never sleeps
Rub_Saifi
Calcite | Level 5

FedSQL for CAS does not support use of non-correlated subqueries with the IN, ANY, and ALL predicates. For example, the following non-correlated subquery is not supported:

 

My log Error:-

NOTE: CAS action completed [OKAY]
FEDSQL: load of action set returned rc=00000000
ERROR: Unsupported operation in FedSQL query: Correlated subquery.
ERROR: Unsupported operation in FedSQL query: IN/ANY/ALL subquery.
ERROR: The action stopped due to errors.
ERROR: The FedSQL action was not successful.
FEDSQL: The fedsql.execDirect action returned rc=0x000003f4 

LinusH
Tourmaline | Level 20

Without knowing more details about your data and specific business logic to be achieved, it's hard to tell how to rewrite the query.

Alternatives could be using EXISTS or some kind of inner join logic?

Data never sleeps

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
  • 3 replies
  • 805 views
  • 0 likes
  • 2 in conversation