Help using Base SAS procedures

how to Merge two tables into new table ?

Accepted Solution Solved
Reply
Regular Contributor
Posts: 240
Accepted Solution

how to Merge two tables into new table ?

i want to combine two tables to one table by using merge..

DAta  report;

merge table1 table2;

run;

Table1 has 200000 records

TAble2. Has 5000 records

when I run the merge I get 13k from table 1 and table2 has 4k

somehow it brings in less record to new table".. Thanks for assistance


Accepted Solutions
Solution
‎01-08-2015 10:48 PM
Super User
Posts: 19,855

Re: how to Merge two tables into new table ?

If you ran it without any changes I doubt its what you want.

Typically you want a BY statement in a merge, so you can join the two tables on some field.

data want;

merge table1 table2;

BY ID;

run;

View solution in original post


All Replies
Respected Advisor
Posts: 3,156

Re: how to Merge two tables into new table ?

Please show your log. The code you showed will not have the result you claimed.

Regular Contributor
Posts: 240

Re: how to Merge two tables into new table ?

Hi Hai kuo

i just reran the script an it merge the correct amount of 200k and 5 k records.... without any changes. To my script could you provide me an example of how it should look since you said mine looks incorrect ...I'm happy that is merging correctly  but don't understand why it didn't first couple times ...thank you again for your assistance

Respected Advisor
Posts: 3,156

Re: how to Merge two tables into new table ?

Glad it worked out for you as it should. What I meant is that your code will not produce the outcome you claimed (13k and 4k) , I didn't say it can't produce something that 'you wanted'.

Solution
‎01-08-2015 10:48 PM
Super User
Posts: 19,855

Re: how to Merge two tables into new table ?

If you ran it without any changes I doubt its what you want.

Typically you want a BY statement in a merge, so you can join the two tables on some field.

data want;

merge table1 table2;

BY ID;

run;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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