%macro import(file,dname);
Proc import datafile="&file" out=&dname
Dbms=excel replace;
Getnames=yes;
Run;
%mend;
%import(E:\sas\macro\data1.xls,ds1);
%import(E:\sas\macro\data2.xls,ds2);
%import(E:\sas\macro\data3.xls,ds3);
%import(E:\sas\macro\data4.xls,ds4);
%import(E:\sas\macro\data5.xls,ds5);
%import(E:\sas\macro\data6.xls,ds6);
%import(E:\sas\macro\data7.xls,ds7);
%import(E:\sas\macro\data8.xls,ds8);
%import(E:\sas\macro\data9.xls,ds9);
%import(E:\sas\macro\data10.xls,ds10);
any other approach import multiple files into sas every time call the macro with file location
A professional approach to move data between environments will not use Excel files as a means of transfer, and avoids the use of PROC IMPORT. Instead have well documented text files, which you read with a data step written according to the documentation.
Such text files can be of variable record length, with either the lines separated by terminators (CR, LF, CRLF), or having a preceding length word (4 bytes binary, you get such from IBM mainframes, SAS provides a specific RECFM for this); or you have fixed-width text files (with or without record terminator).
In the case of variable length lines, one usually has delimiters between the columns, or only the last column variable (once again, typical for mainframes).
In a professional environment, a macro like yours would therefore only make sense if all files had the same structure, and if that is the case, you do not use a macro, but a single data step using the FILEVAR= option (all data ends therefore up in a single dataset, and an "origin" variable might be kept).
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.