BookmarkSubscribeRSS Feed
Sandhya
Fluorite | Level 6
Hi,

Is it possible to merge multiple datasets in one proc sql.

I have 3 tables. Each of them have same id but different join_date and term_date. I want a dataset which holds the data for each id join_date and term_date.

I tried data step, but it doesn't take the multiple records on the same id value.

Thanks in advance,
Sandhya.
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
It's best to share whatever code you have tried, preferably in a SAS-generated log output with all statements revealed (not just your source code window).

Also, share a data-sample, as well - both for the INPUT side and the expected/desired OUTPUT side, listed in a post-reply.

Scott Barry
SBBWorks, Inc.
Doc_Duke
Rhodochrosite | Level 12
Something like this, untested code,

PROC SQL;
CREATE TABLE abc AS
SELECT a.*, b.join_date, c.term_date
FROM a, b, c
WHERE a.id=b.id AND a.id=c.id;

That will do an inner join keeping all the columns from a and just the respective dates from b and c. A left join would be similar; you can find the specifics in the SQL manual.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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