Given the following SAS data set and macro, could someone please provide an explanation as to why the first 3 calls to the macro execute without errors but the 4th call produces the error message as listed below. If I don't use a default value for "code" (change the “code=A11” to “code”) in the macro definition, then all 4 calls execute without error. Why is this? I have tried exiting the SAS session and restarting but it didn't help.
New to SAS. Thank you. Much Appreciated. :)
------------------- begin code block -----------------------------------
/* data set definition */
data dat5;
infile datalines truncover;
input Year Prod_Cd $ Sales;
datalines;
2001 A11 100
2001 B12 200
2002 C13 300
;
run;
/* macro definition */
%macro sel(code=A11);
proc sql;
select * from dat5
where Prod_Cd = "&code";
quit;
%mend;
/* calls to the macro */
%sel(); /* 1st call */
%sel(code=A11); /* 2nd call */
%sel(code=A12); /* 3rd call */
%sel(A11); /* 4th call */
--------------------end code block--------------------------------------
/* SAS log message for the 4th call to the macro */
128 %macro sel(code=A11);
129 proc sql;
130 select * from dat5
131 where Prod_Cd = "&code";
132 quit;
133 %mend;
134
135 %sel(A11);
MLOGIC(SEL): Beginning execution.
ERROR: More positional parameters found than defined.
MLOGIC(SEL): Parameter CODE has value A11
MLOGIC(SEL): Ending execution.
------------------------------------------------------------------------