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

Hi Colleagues,

I have these 2 datasets.

data table_1;

input Account_number;

cards;

11111111

12222222

;

run;

data table_2;

input Account_number Account_name $ 10-26;

cards;

11111111 AAAAA IIIII LLLL 

100000   WWWWWWW SSSSS DDD

100002   TTTTTT EEEEEEE   

102222   NNNNNN

12222222 OOOOOO YYYYYYY   

;

run;

Question:

When join the above 2 tables using below code, it does the job correctly but a warming comes in the log like this:

/*WARNING: Variable Account_number already exists on file WORK.ANY_NAME.

*/

How come this? How could I get rid of it?

proc sql;

     create table any_name as

     select     a.*        ,

                b.*

from       table_1    a,

           table_2    b

where a.account_number=b.account_number;

quit;

Your heilp is greatly appreciated.

Thanks

Mirisage

1 ACCEPTED SOLUTION

Accepted Solutions
DanielSantos
Barite | Level 11

Just loose the a.* in the select

proc sql;

     create table any_name as

     select     a.*        ,

                b.*

from       table_1    a,

           table_2    b

where a.account_number=b.account_number;

quit;


Since you're selecting just the key from A, and the where clause restricts the query to a inner join (same value on both sides), it' doesn't matter from which table comes the Account_Number.

Cheers from Portugal.

Daniel Santos @ www.cgd.pt

View solution in original post

3 REPLIES 3
DanielSantos
Barite | Level 11

Just loose the a.* in the select

proc sql;

     create table any_name as

     select     a.*        ,

                b.*

from       table_1    a,

           table_2    b

where a.account_number=b.account_number;

quit;


Since you're selecting just the key from A, and the where clause restricts the query to a inner join (same value on both sides), it' doesn't matter from which table comes the Account_Number.

Cheers from Portugal.

Daniel Santos @ www.cgd.pt

JerryH
Calcite | Level 5

In case you have two data sets that have multiple variables you wish to keep, you can use the <dsnam>* approach for one but for the other you need to specify the variables you wish to extract from it but not the key variable.  You will then not get tthat warning

Mirisage
Obsidian | Level 7

Hi Jerry,

Thank you very much for your inputs.

Regards

Mirisage


SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1099 views
  • 0 likes
  • 3 in conversation