I'm trying to use a %DO loop to append multiple monthly data files. Here's the code I have so far:
options mprint symbolgen source mlogic merror syntaxcheck ;
%MACRO INT;
%DO i=01 %TO 03 %BY 1;
libname appd "Qual1.Qual2.Qual3.QUAL416&i." disp=shr;
data work&i.;
set appd.file;
run;
data final;
set work;
run;
proc append data=work&i.
base=final;
run;
%MEND;
%INT;
I'm getting an error :
WARNING: The quoted string currently being processed has become more than 262 characters long. You might have unbalanced quotation marks.
I've never received this error before, and I'm not entirely sure what it means. I'm trying to create this macro to append a few files from this year, but ideally it would span across multiple years. i.e. changing mtro16&i. to mtro&i. EXCEPT I don't want to have to code %DO i=1601 %TO 1612 %BY 1
explicitly, because I will have to change it for every year, e.g. if I begin in 2010, i'll have to code 2010, then a separate %DO
statement for 2011, etc. all the way until 2016. This doesn't sound like much, but across a decade >+ it can be.
UPDATE: I changed my code to include this bit:
`%DO i=1005 %TO 1607;
%IF i=1013 %THEN %DO i=1101 %TO 1112;
/*%ELSE %IF i=1113 %THEN %DO i=1201 %TO 1212;*/
/*%ELSE %IF i=1213 %THEN %DO i=1301 %TO 1312;*/
/*%ELSE %IF i=1313 %THEN %DO i=1401 %TO 1412;*/
/*%ELSE %IF i=1413 %THEN %DO i= 1501 %TO 1512;*/
/*%ELSE %IF i=1513 %THEN %DO i=1601 %TO 1607;*/`
It's kind of janky, but I thought it would work to only loop to the end of the year and then begin the next iteration after i=1012 to i=1101
. However, this is what is happening in my log:
MLOGIC(INT): %DO loop index variable I is now 1012; loop will iterate again.
MLOGIC(INT): %IF condition i=1013 is FALSE
MLOGIC(INT): %DO loop index variable I is now 1013; loop will iterate again.
MLOGIC(INT): %IF condition i=1013 is FALSE
How is SAS treating this %IF
condition? It tells me that variable i = 1013
and that %IF
condition i=1013
is FALSE? Why is this not TRUE?
SET WORK01 - WORK03;
– Tom