BookmarkSubscribeRSS Feed
Sandeep77
Lapis Lazuli | Level 10

Hi Experts,

I am adding current balance details in the table but getting unresolved errors.

I have checked the accountkey in table a and b are numeric. Can you please suggest what's causing the errors?

proc sql;
create table adding_accountkey as 
select a.*,
b.accountkey
from work.stamped_result as a
left join dwhdw.dim_account as b on a.debt_code =b.accountnumber 
order by debt_code;
quit;
(Till here it works perfect. The errors come in the second code)


proc sql;
  create table Current_balance as
  select 
a.*,
b.CurrentBalance
  from work.adding_accountkey as a 

        left join dwhdw.fact_snapshot_accountstatus as a
        on a.accountkey = b.accountkey      ;
quit;

Error in the log:
30         proc sql;
31           create table Current_balance as
32           select
33         a.*,
34         b.CurrentBalance
35           from work.adding_accountkey as a
36         
37                 left join dwhdw.fact_snapshot_accountstatus as a
38                 on a.accountkey = b.accountkey
39         
40         ;
ERROR: Column a.accountkey was found in more than one table in the same scope.
ERROR: Unresolved reference to table/correlation name b.
WARNING: Correlation name a identifies more than one table.
ERROR: Unresolved reference to table/correlation name b.
ERROR: Expression using equals (=) has components that are of different data types.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
41         quit;
NOTE: The SAS System stopped processing this step because of errors.
2 REPLIES 2
ballardw
Super User
  from work.adding_accountkey as a 

        left join dwhdw.fact_snapshot_accountstatus as a

You used the same alias, A, for both data sets. One of these A have to be B to use b.anyvariablename

Reeza
Super User
  from work.adding_accountkey as a 

        left join dwhdw.fact_snapshot_accountstatus as a

You've aliased both tables as A. 

 

Change one to B.

 


@Sandeep77 wrote:

Hi Experts,

I am adding current balance details in the table but getting unresolved errors.

I have checked the accountkey in table a and b are numeric. Can you please suggest what's causing the errors?

proc sql;
create table adding_accountkey as 
select a.*,
b.accountkey
from work.stamped_result as a
left join dwhdw.dim_account as b on a.debt_code =b.accountnumber 
order by debt_code;
quit;
(Till here it works perfect. The errors come in the second code)


proc sql;
  create table Current_balance as
  select 
a.*,
b.CurrentBalance
  from work.adding_accountkey as a 

        left join dwhdw.fact_snapshot_accountstatus as a
        on a.accountkey = b.accountkey      ;
quit;

Error in the log:
30         proc sql;
31           create table Current_balance as
32           select
33         a.*,
34         b.CurrentBalance
35           from work.adding_accountkey as a
36         
37                 left join dwhdw.fact_snapshot_accountstatus as a
38                 on a.accountkey = b.accountkey
39         
40         ;
ERROR: Column a.accountkey was found in more than one table in the same scope.
ERROR: Unresolved reference to table/correlation name b.
WARNING: Correlation name a identifies more than one table.
ERROR: Unresolved reference to table/correlation name b.
ERROR: Expression using equals (=) has components that are of different data types.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
41         quit;
NOTE: The SAS System stopped processing this step because of errors.

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 673 views
  • 0 likes
  • 3 in conversation