Posted By

sarathannapareddy on 11/01/09


Tagged

merge macros datastep sas


Versions (?)

Merging the data sets with a common variable if the datasets has the same prefix name?


 / 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).

  1. %macro allmerge (n);
  2. data combine;
  3. merge
  4. %do i = 1 % to &n;
  5. dsn&i
  6. %end;
  7. ; /* this additional ';' is necessary, the first ';' is for
  8. the "%end", while the second ';' is for "Merge" */
  9. by usubjid;
  10. run;
  11. %mend;
  12. %allmerge (7)
  13.  
  14. http://studysas.blogspot.com/2009/02/merging-data-sets-using-macro-code.html

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: sarathannapareddy on November 1, 2009

%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)

You need to login to post a comment.