Hello,
The following program was taken from this paper where %NRBQUOTE (%NRQUOTE) is used to quote macro parameter value. (http://www.lexjansen.com/phuse/2014/cc/CC02.pdf)
%MACRO Ex_3(Food);
%IF (&Food EQ %NRSTR(Rice & Beans)) %THEN
%PUT Try the House Special - &Food;
%ELSE %PUT &Food - a tasty snack!;
%MEND Ex_3;
%Ex_3(%NRBQUOTE(Rice & Beans));
When I use %NRSTR as macro quoting function for parameter value I get the same result. So in this situation both compile time and execution time macro quoting functions can be used?
%MACRO Ex_3(Food);
%IF (&Food EQ %NRSTR(Rice & Beans)) %THEN
%PUT Try the House Special - &Food;
%ELSE %PUT &Food - a tasty snack!;
%MEND Ex_3;
%Ex_3(%NRSTR(Rice & Beans));
Hello,
in your example there is no diiference in the result no matter you use %NRBQUOTE or %NRSTR.
But consider the following examples (where Rice&Beans are written without any space) and you may notice the difference between them.
%MACRO Ex_3(Food);
%IF (&Food EQ %NRSTR(Rice&Beans)) %THEN
%PUT Try the House Special - &Food;
%ELSE %PUT &Food - a tasty snack!;
%MEND Ex_3;
/*macro variable &beans is not resolved therefore besides the put message
there is also an warning message in the log*/
%Ex_3(%NRBQUOTE(Rice&Beans));
/*macro variable &beans is maske therefore the put message written in the log*/
%Ex_3(%NRSTR(Rice&Beans));
Yes. %NRBQUOTE is usually for macro variable. Since you don't have any macro variable in parameter ,
no macro variable would be explained in %NRBQUOTE . Both %NRBQUOTE and %NRSTR(is for text) would be accepted.
You are quoting in the wrong place. You do not need to quote your example value in the macro call. You need to quote the value in the implied %EVAL() function call that the %IF statement is generating.
%MACRO Ex_3(Food);
%IF (%superq(food) EQ %NRSTR(Rice & Beans)) %THEN
%PUT Try the House Special - &Food;
%ELSE %PUT &Food - a tasty snack!;
%MEND Ex_3;
%Ex_3(Rice & Beans);
Hello,
in your example there is no diiference in the result no matter you use %NRBQUOTE or %NRSTR.
But consider the following examples (where Rice&Beans are written without any space) and you may notice the difference between them.
%MACRO Ex_3(Food);
%IF (&Food EQ %NRSTR(Rice&Beans)) %THEN
%PUT Try the House Special - &Food;
%ELSE %PUT &Food - a tasty snack!;
%MEND Ex_3;
/*macro variable &beans is not resolved therefore besides the put message
there is also an warning message in the log*/
%Ex_3(%NRBQUOTE(Rice&Beans));
/*macro variable &beans is maske therefore the put message written in the log*/
%Ex_3(%NRSTR(Rice&Beans));
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.