Help using Base SAS procedures

Merging multiple dataset

Reply
Contributor
Posts: 57

Merging multiple dataset

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.
Super Contributor
Super Contributor
Posts: 3,174

Re: Merging multiple dataset

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.
Trusted Advisor
Posts: 2,113

Re: Merging multiple dataset

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.
Ask a Question
Discussion stats
  • 2 replies
  • 142 views
  • 0 likes
  • 3 in conversation