Nested macro definition causes :Open code statement recursion detected. however move the nested macro definition to outside of main macro will cure the code. But why? Syntax-wise they are both valid. Anyone can explain to me? Thank you. ####### %macro upcaseDSN(dsn);
%macro NameWithoutLibOpt(dsn);
%if %index(&dsn,.) %then %scan(&dsn,2,%str(.%());
%else %scan(&dsn,1,%str(.%());
%mend;
%upcase(%NameWithoutLibOpt(&dsn))
%mend;
%put %upcaseDSN(%str(sashelp.class(keep=age)));
%* expect to see CLASS but failed; Error message 252
253
254 %macro upcaseDSN(dsn);
255 %macro NameWithoutLibOpt(dsn);
256 %if %index(&dsn,.) %then %scan(&dsn,2,%str(.%());
257 %else %scan(&dsn,1,%str(.%());
258 %mend;
259 %upcase(%NameWithoutLibOpt(&dsn))
260 %mend;
261 %put %upcaseDSN(%str(sashelp.class(keep=age)));
MLOGIC(UPCASEDSN): Beginning execution.
MLOGIC(UPCASEDSN): Parameter DSN has value sashelp.class(keepage)
ERROR: Open code statement recursion detected.
SYMBOLGEN: Macro variable DSN resolves to sashelp.class(keep=age)
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been
unquoted for printing.
ERROR: Expected %DO not found.
ERROR: Skipping to next %END statement. modified code are fine. but why? %macro NameWithoutLibOpt(dsn);
%if %index(&dsn,.) %then %scan(&dsn,2,%str(.%());
%else %scan(&dsn,1,%str(.%());
%mend;
%macro upcaseDSN(dsn);
%upcase(%NameWithoutLibOpt(&dsn))
%mend;
%put %upcaseDSN(%str(sashelp.class(keep=age)));
%* get CLASS by moving nested macro out ; 273 %* get CLASS by moving nested macro out ;
274 option nosymbolgen nomlogic;
275 %macro NameWithoutLibOpt(dsn);
276 %if %index(&dsn,.) %then %scan(&dsn,2,%str(.%());
277 %else %scan(&dsn,1,%str(.%());
278 %mend;
279
280 %macro upcaseDSN(dsn);
281
282 %upcase(%NameWithoutLibOpt(&dsn))
283 %mend;
284 %put %upcaseDSN(%str(sashelp.class(keep=age)));
CLASS
285 %* get CLASS by moving nested macro out ;
... View more