/ Published in: SAS
URL: http://studysas.blogspot.com/2009/02/merging-data-sets-using-macro-code.html
For example: col1-col10 dsn1-dsn 7 data1 to data6 with common variable of Usubjid.
here is the example, I have 7 datasets i need to merge and each of them having the common variable(usubjid) to merge, and all the datasets having the same prefix dsn(dsn1 to dsn7).
Expand |
Embed | Plain Text
%macro allmerge (n); data combine; merge %do i = 1 % to &n; dsn&i %end; ; /* this additional ';' is necessary, the first ';' is for the "%end", while the second ';' is for "Merge" */ by usubjid; run; %mend; %allmerge (7) http://studysas.blogspot.com/2009/02/merging-data-sets-using-macro-code.html
Comments
Subscribe to comments
You need to login to post a comment.

%macro allmerge (n); data combine; merge %do i = 1 % to &n; dsn&i %end; ; /* this additional ';' is necessary, the first ';' is for the "%end", while the second ';' is for "Merge" */ by usubjid; run; %mend; %allmerge (7)