Hello Forum,
I have following code that uses %nrbquote and %superq to give the same results. I was curious what is the difference between them. Can I use %nrbquote in place of %superq and vice vera? Thanks for any insights.
%let a=%nrstr(Kaushal&Alex);
%let c=%nrquote(&a);
%put &c;
%let a=%nrstr(Kaushal&Alex);
%let c=%superq(a);
%put &c;
Kaushal,
In Loko's code, there was a live (unquoted) & captured by CALL SYMPUT.
In your code, the & is quoted by %nrstr. All the subsequent quoting functions maintain the quoted status of the &, thus there is no resolution of &Alex.
To illustrate, also try:
%put %unquote(&c);
It's always a good thing to run tests when using quoting functions in macro language!
Good luck.
https://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a001061316.htm
For %superq its on the left in the tree view.
Hello,
I have also tried to figure out differences between the 2 functions and I could hardly find. There is one situation where I have found differences :
data _null_;
call symput('word', 'ben&jerry');
run;
%put &word;
%put %nrbquote(&word); -->ISSUES WARNING
%put %superq(word);-->DOES NOT ISSUE WARNING
Loko,
%nrbquote will continue to resolve macro variable references. To see the difference (and perhaps shed some light on why you get a warning), try adding this statement before you run your code:
%let jerry=jamin;
Hello Astounding,
In this code, I am not sure why macro variable Alex is not resolved in %nrbquote? As you mentioned "%nrbquote will continue to resolve macro variable references".
%let Alex=Jamin;
%let a=%nrstr(Kaushal&Alex);
%let c=%nrquote(&a);
%put &c;
Kaushal,
In Loko's code, there was a live (unquoted) & captured by CALL SYMPUT.
In your code, the & is quoted by %nrstr. All the subsequent quoting functions maintain the quoted status of the &, thus there is no resolution of &Alex.
To illustrate, also try:
%put %unquote(&c);
It's always a good thing to run tests when using quoting functions in macro language!
Good luck.
Great !!! Thanks a bunch, Astounding.
SUPERQ masks the same characters as the %NRBQUOTE function. However, %SUPERQ does not attempt to resolve anything in the value of a macro variable. %NRBQUOTE attempts to resolve any macro references or macro variable values in the argument before masking the result.
SUPERQ is the only quoting function that prevents the resolution of macro variables and macro references in the value */
of the specified macro variable.*/
SUPERQ accepts only the name of a macro variable as its argument, without an ampersand, and the other quoting functions accept any text expression, including constant text, as an argument.*/
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!
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.