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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.