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.

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
  • 2 replies
  • 827 views
  • 0 likes
  • 3 in conversation