%let e=""xyz"" ;
%put %substr(&e,3,2);
when I am executing above programming I am getting error like
ERROR: Open code statement recursion detected.
You do not need the quotation marks around xyxz
The problem is that the range specified is out of bounds. Try this
%let e=xyz;
%put %substr(&e,2,1);
@thanikondharish wrote:
Don't remove quotations
Quoting values when assigning macro-variables is a bad idea in most cases i have seen in the last decade. It is almost always better to use the quotes when you want the value of the variable inserted into sas code.
First, figure out what you are working with. Try this test initially:
%put **&e**;
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:
1 %let e=""xyz"" 2 %put %substr(&e,3,2); ERROR: Open code statement recursion detected. 3 ; 4 %put %substr(&e,3,2); xy
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
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); "
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: