Excel files are very ill-suited for this, as the import into SAS (via LIBNAME XLSX or PROC IMPORT) will produce different column attributes (even the type, character or numeric!) depending on the contents.
If you have clean, constant content (fixed length, no completely missing columns), something like this might work:
%macro imp_excel(filename);
proc import
datafile="&filename"
out=temp
dbsm=xlsx
replace
;
run;
proc append
data=temp
base=want
force
;
run;
%mend;
data _null_;
length fref $8 fname $200;
rc = filename(fref,"path_to_your_excel_files");
did = dopen(fref);
if did ne 0
then do;
do i = 1 to dnum(did);
fname = catx("/","path_to_your_excel_files",dread(did,i));
if lowcase(scan(fname,-1,'.')) = 'xlsx' then call execute(cats('%imp_excel(',fname,')'));
end;
rc = dclose(did);
end;
rc = filename(fref);
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.