Help using Base SAS procedures

Partial Merger of two data steps

Reply
New Contributor
Posts: 3

Partial Merger of two data steps

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)
Super Contributor
Super Contributor
Posts: 365

Re: Partial Merger of two data steps

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
New Contributor
Posts: 3

Re: Partial Merger of two data steps

Thanks
Ask a Question
Discussion stats
  • 2 replies
  • 255 views
  • 0 likes
  • 2 in conversation