Good morning! I have been testing out importing multiple sheets from 1 excel book by using a %Do loop within a macro. I want to import the sheets based upon their naming conventions in this case 201701, 201702, 201703,..... 201712. The issue that I am having is that for sheets 201701-201709, SAS is telling me that it cannot find the sheets. It does however import for sheets 201710 - 201712. Here is the code that I am using: %macro importy1; %if &year1. >2018 %THEN %DO; %do i = 1 %to 4; Proc Import out= WORK.RS_&Year1._Q&i DATAFILE= Y1RS DBMS=xlsx REPLACE; SHEET="&Year1. Q&i"; GETNAMES=YES; RUN; %END; %END; %else %if &year1.<= 2018 %then %do; %do i = 1 %to 12; %if i < 10 %then %do; Proc Import out= WORK.RS_&Year1.0&i DATAFILE= Y1RS DBMS=xlsx REPLACE; SHEET="&Year1.0&i"; GETNAMES=YES; RUN; %END %ELSE %IF i > 9 %then %do; Proc Import out= WORK.RS_&Year1.&i DATAFILE= Y1RS DBMS=xlsx REPLACE; SHEET="&Year1.&i"; GETNAMES=YES; RUN; %end %end; %end; %MEND IMPORTy1; %importy1; From what I can tell, the issue is that the 0 in the <10 statement is not being interpreted correctly, however I do not know how to correct this. If you could provide any insight on how to remedy this it would be greatly appreciated. Thanks!
... View more