/*Example Code for Merging Datasets*/ libname hanes 'C:\Data'; /*Each dataset to be merged must be sorted on merging variable SP_ID*/ proc sort data=hanes.spfile out=spfile; by sp_id; proc sort data=hanes.capi out=capi; by sp_id; proc sort data=hanes.exam out=exam; by sp_id; data example; merge spfile (in=a) capi exam (in=b); by sp_id; if a and b; /*Merges SPs in both the SPfile and Exam datasets*/ run;