DATA Step, Macro, Functions and more

Merge 2 datasets - common rows

Reply
Occasional Contributor
Posts: 11

Merge 2 datasets - common rows

[ Edited ]

I know how to merge 2 datasets.

 

Can someone please tell me how to merge 2 datasets rows common to both the datasets.

Super User
Posts: 17,831

Re: merge 2 datasets

[ Edited ]

We can't understand your question. 

Please post sample input and output data to illustrate your issue. 

 

EDIT: Here's the SAS resource on combining datasets and all the different ways.

http://support.sas.com/documentation/cdl/en/basess/68381/HTML/default/viewer.htm#p19t3r1gxavpoin14jd...

Super User
Super User
Posts: 7,401

Re: merge 2 datasets

Refer to this visual below which shows SQL code, however the same is possible in datastep merge using in= on both datasets:

data want;
  merge have1 (in=a) have2 (in=b);
  by merge_variables;
  if a and b;
run;

Capture.PNG

Ask a Question
Discussion stats
  • 2 replies
  • 126 views
  • 1 like
  • 3 in conversation