Hi there, SAS newbie here. I have a SAS library of 40+ files the following dataset name pattern: McDonalds McDonaldsFile2 BurgerKing Wendys WendysFile2 WendysFile3 PizzaHut All of these files share the same column names. So some companies have just one file, whereas others have more than one file. I am trying to write a macro to combine each company’s files into one dataset. So McDonalds = McDonalds + McDonaldsFile2, and Wendys = Wendys + WendysFile2 + WendysFile3. The other companies with just one file should stay intact. Here is the code I’ve tried: proc contents data=abc._all_ out=abccont(keep=memname) noprint;
run;
proc sort data=abccont nodupkey;
by memname;
run;
data _null_;
set abccont end=last;
by memname;
i+1;
call symputx('name'||trim(left(put(i,8.))),memname);
if last then call symputx('count',i);
run;
%macro combine;
%do n = 1 %to &count;
data &memname;
set
%do j = 2 %to 3;
cats(&memname,’File’,&i);
%end;
run;
%mend combine;
%combine; I have spent hours searching the forums and google, but to no avail. Any help would be appreciated.
... View more