BookmarkSubscribeRSS Feed
MARS
Calcite | Level 5
Can some please help me on following issue.

I want to merge two sas datasets to create a new data set.

However, I only need to few specific variables from the second data set to be included in the new merged data set.

Can somebody tell me the SAS-CODE to use for this purpose i.e two include only specific variables from one data set in the merge step.

(Please not that I have very huge data sets)
2 REPLIES 2
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Mars,

These are two common approaches to your problem:
a) with a datastep (d1 and d2 should be sorted by X before merging):
data c;
merge d1(in=d1ind) d2(keep=X A B);
if d1ind;
by X;
run;
a) with proc SQL:
proc SQL;
create table c as
select a.*, b.A, b.B
from d1 as a left join d2 as b on a.X=b.X
;quit;
Sincerely,
SPR
MARS
Calcite | Level 5
Thanks

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1137 views
  • 0 likes
  • 2 in conversation