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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

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
  • 3 in conversation