BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
arnouxvr
Fluorite | Level 6

I have been struggling with an issue.

 

Looking at the code below:

 

 

%put %scan(%str(arg1=A,arg2=B,arg3=C),1);

%let string = arg1=A,arg2=B,arg3=C;

%put %scan(%str(&string),1);

 

 

The first %put statement writes arg1=A in the log as expected.

 

The second %put statement gives a warning.

 

WARNING: Argument 2 to macro function %SCAN is out of range.

 

My question is:

 

How do I force the %put statement to first resolve the macro variable &string to arg1=A,arg2=B,arg3=C and then execute the %put statement?

1 ACCEPTED SOLUTION

Accepted Solutions
kiranv_
Rhodochrosite | Level 12

this should work as 

The %STR and %NRSTR functions mask a character string during compilation of a macro or macro language statement. They mask the following special characters and mnemonic operators:

 

to make it work  during execution use %bquote

 

 

%put %scan(%str(arg1=A,arg2=B,arg3=C),1);
/*complilation*/
%let string = %str(arg1=A,arg2=B,arg3=C);
%put %scan(&string,1);
/*bquote During execution*/
%let string9 = arg1=A,arg2=B,arg3=C;
%put %scan(%bquote(&string9),1);

 

View solution in original post

1 REPLY 1
kiranv_
Rhodochrosite | Level 12

this should work as 

The %STR and %NRSTR functions mask a character string during compilation of a macro or macro language statement. They mask the following special characters and mnemonic operators:

 

to make it work  during execution use %bquote

 

 

%put %scan(%str(arg1=A,arg2=B,arg3=C),1);
/*complilation*/
%let string = %str(arg1=A,arg2=B,arg3=C);
%put %scan(&string,1);
/*bquote During execution*/
%let string9 = arg1=A,arg2=B,arg3=C;
%put %scan(%bquote(&string9),1);

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1888 views
  • 2 likes
  • 2 in conversation