- %kbmerge: ``Keep both'' merge keeps an observation if it is in either of the input datasets. In addition, it creates variables that tell you which dataset an observation came from:
  
%macro kbmerge(inds1, inds2, byvar, outds);
    proc sort data=&inds1 nothreads;
			      by &byvar;
        
    proc sort data=&inds2 nothreads;
        by &byvar;
    
    data &outds;
        merge &inds1(in=a) &inds2(in=b);
        by &byvar;
        if a or b;
        in&inds1=a;
        in&inds2=b;
    run;
%mend;
   
 
- %kfmerge: ``keep first'' merge keeps only observations from the first dataset. This is just %stdmerge with the ``if'' line replaced.
 
%macro kfmerge(inds1, inds2, byvar, outds);
    proc sort data=&inds1 nothreads;
        by &byvar;
        
    proc sort data=&inds2 nothreads;
        by &byvar;
    
    data &outds;
        merge &inds1(in=a) &inds2(in=b);
        by &byvar;
        if a;
    run;
%mend;
 
- %rmsecmerge: ``remove second'' merge removes the observations from the first dataset that occur in the second. The only difference again is the if line:
  
%macro rmsecmerge(inds1, inds2, byvar, outds);
    proc sort data=&inds1 nothreads;
        by &byvar;
        
    proc sort data=&inds2 nothreads;
        by &byvar;
    
    data &outds;
        merge &inds1(in=a) &inds2(in=b);
        by &byvar;
        if not b;
    run;
%mend;