The method described by @Tom is exactly what you need when running SAS from a PC SAS installation. But if you are working in a company, often you will have a SAS client-server setup, where you use Enterprise Guide or SAS Studio to write and submit code that actually runs on a SAS compute server located on a different machine. Setting the SAS invocation option NOXCMD is the default in those situations, and you won't be able to use FILENAME PIPE, X, SYSEXEC, or other code that executes arbitrary O/S commands on the compute server. And most system administrators will be more comfortable leaving that setting as-is.
To work with file system files and directories in those cases, consider using the base SAS functions designed for that (FILENAME, DOPEN, DREAD, DCLOSE, FOPEN, FOPTNAME, FREAD, FCLOSE, etc.). These can be executed even with NOXCMD in effect, and as an added bonus, don't require you to know what O/S underlies your SAS session or to be familiar with DOS or Linux syntax. You can experiment with those yourself, or you can try out the macros I personally use for jobs like this. I've shared these macros on Github (https://github.com/SASJedi/sas-macros).
If your SAS can access internet assets, you can use this SAS code to compile the macros in your SAS session:
/* Get the necessary macro files rom GitHub */
filename getmacro url "https://raw.githubusercontent.com/SASJedi/sas-macros/master/findfiles.sas";
%include getmacro;
filename m1 url "https://raw.githubusercontent.com/SASJedi/sas-macros/master/exist.sas";
%include getmacro;
filename getmacro url "https://raw.githubusercontent.com/SASJedi/sas-macros/master/translate.sas";
%include getmacro;
filename getmacro url "https://raw.githubusercontent.com/SASJedi/sas-macros/master/fileattribs.sas";
%include getmacro;
filename getmacro;
Once you have the macros, you can ask for syntax help using a question mark, like this:
%findFiles(?)
And to use this macro to solve the problem you presented, I'd do something like this:
/* Put the path to your Excel file folder here: */
%let path= ;
%findFiles(&path,xls,work.ExcelFiles)
proc sql noprint;
select filename
into:thisfile
from work.ExcelFiles
where lowcase(filename) like 'xlfile.%'
order by input(substr(filename,8,10),mmddyy10.) desc
;
quit;
PROC IMPORT OUT=WANT
DATAFILE= "&path\&thisfile"
DBMS=EXCEL REPLACE;
RUN;
May the SAS be with you!
Mark