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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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