Hello @thanikondharish,
Normally your code should work, as shown in the log below:
1 %let e=""xyz"";
2 %put %substr(&e,3,2);
xy
(Note that the four quotation marks got part of the macro variable value.)
So the error message is most likely the result of submitting different code before (see your log).
Examples include:
Missing semicolon after the %LET statement (see line 1 below). In this situation submit a single semicolon (line 3) to repair the damage. Then submit the %PUT statement again (line 4) and add the missing semicolon in the code.
1 %let e=""xyz""
2 %put %substr(&e,3,2);
ERROR: Open code statement recursion detected.
3 ;
4 %put %substr(&e,3,2);
xy
Unbalanced quotes in the %LET statement (see line 1 below). In this situation submit the missing quotation mark followed by a semicolon (line 3) to repair the damage. Then add the missing quotation mark in the code and submit both statements again (lines 4, 5).
1 %let e=""xyz";
2 %put %substr(&e,3,2);
ERROR: Open code statement recursion detected.
3 ";
4 %let e=""xyz"";
5 %put %substr(&e,3,2);
xy
Unbalanced quote(s) in the expression in the %PUT statement (after resolution, see line 2 below) and then trying to submit one or both of the statements again (line 3) because the %PUT statement "didn't work." In this situation, similar to the previous bullet point, submit a quotation mark followed by a semicolon (line 4) to repair the damage. Then submit the corrected %PUT statement so that it doesn't create an unprotected, unbalanced quotation mark (line 5 or line 6). The %QSUBSTR function (line 6) masks the quotation mark and thus avoids the problem.
1 %let e=""xyz"";
2 %put %substr(&e,1,1);
ERROR: Open code statement recursion detected.
3 %put %substr(&e,1,1);
4 ";
";"
5 %put %substr(&e,3,2);
xy
6 %put %qsubstr(&e,1,1);
"
... View more