%MACRO excel (OUTPUT=,INFILE=,WSHEET=);
PROC import OUT= &OUTPUT
DATAFILE="P:\FALL COURSES 2020\SAS\final project\&INFILE"
DBMS=xls;
SHEET="&WSHEET";
PROC CONTENTS DATA=&OUTPUT;
PROC SORT DATA=&OUTPUT;
BY ID;
RUN;
%MEND excel;
%excel(OUTPUT=Site1,INFILE=Site1.XLS,WSHEET=SHEET1);
%excel(OUTPUT=Site2,INFILE=Site2.XLS,WSHEET=SHEET1);
ERROR: File WORK.SITE2.DATA does not exist.
The last ERROR is always the least important. The first ERROR or WARNING is most important.
And before you start making code dynamic, make sure that it works.
Run your import code without any macro variables, and post the complete log of the step if it fails. Use a window opened with </> to post the log.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.