Hi All,
I have a couple of macro variables in my SAS code which contains the list of variables. i.e.
%let list1= var1 var2 var3 var4 ........ ;
%let list2= var10 var15 var60 ; (few variables from list1)
%let uplist1=%upcase(%str(&list1.));
%let uplist2=%upcase(%str(&list2.));
When I run the above code, I am getting the error Open code statement recursion detected'
Is there any way to remove it, please?
Thank you!
@Sami1234 wrote:
Hi All,
I have a couple of macro variables in my SAS code which contains the list of variables. i.e.
%let list1= var1 var2 var3 var4 ........ ;
%let list2= var10 var15 var60 ; (few varaibles from list1)
%let uplist1=%upcase(%str(&list1.));
%let uplist2=%upcase(%str(&list2.));
When I run the above code, I am getting the error Open code statement recursion detected'
Is there any way to remove it, please?
Thank you!
Since the only reason you would need to use %str in
%let uplist1=%upcase(%str(&list1.)); %let uplist2=%upcase(%str(&list2.));
would be the inclusion of special characters of some sort then perhaps you need to show the entire list of actual values for List1 and list2
Example:
%let list1= var1 var2 var3 var4 ........ ; %let uplist1=%upcase(&list1.); %put &uplist1.;
As soon as you start placing other than simple text into your variable then the actual text matters, especially if it includes macro triggers like & or % (in which case you may need %NRSTR instead of %str)
Note that a missing ; on a let statement might be place to start as this will duplicate the error:
2965 %let list1= var1 var2 var3 var4 ........ 2966 2967 %let uplist1=%upcase(&list1.); ERROR: Open code statement recursion detected.
This error indicates that you've got a syntax error somewhere in your macro code - a missing semicolon for example. The code you've posted looks o.k. though.
@Sami1234 wrote:
Hi All,
I have a couple of macro variables in my SAS code which contains the list of variables. i.e.
%let list1= var1 var2 var3 var4 ........ ;
%let list2= var10 var15 var60 ; (few varaibles from list1)
%let uplist1=%upcase(%str(&list1.));
%let uplist2=%upcase(%str(&list2.));
When I run the above code, I am getting the error Open code statement recursion detected'
Is there any way to remove it, please?
Thank you!
Since the only reason you would need to use %str in
%let uplist1=%upcase(%str(&list1.)); %let uplist2=%upcase(%str(&list2.));
would be the inclusion of special characters of some sort then perhaps you need to show the entire list of actual values for List1 and list2
Example:
%let list1= var1 var2 var3 var4 ........ ; %let uplist1=%upcase(&list1.); %put &uplist1.;
As soon as you start placing other than simple text into your variable then the actual text matters, especially if it includes macro triggers like & or % (in which case you may need %NRSTR instead of %str)
Note that a missing ; on a let statement might be place to start as this will duplicate the error:
2965 %let list1= var1 var2 var3 var4 ........ 2966 2967 %let uplist1=%upcase(&list1.); ERROR: Open code statement recursion detected.
Thank you so much for your reply!
Actually, it's not throwing any error or warning now by using the following code, running within the macro
%let list1= var1 var2 var3 var4 ........ ;
%let list2= var10 var15 var60 ; (few varaibles from list1)
%let uplist1=%unquote(%upcase(%str(&list1.)));
%let uplist2=%unquote(%upcase(%str(&list2.)));
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.