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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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.

View solution in original post

7 REPLIES 7
Loko
Barite | Level 11

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

Astounding
PROC Star

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;

kaushal2040
Calcite | Level 5

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;

Astounding
PROC Star

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.

kaushal2040
Calcite | Level 5

Great !!! Thanks a bunch, Astounding.

sas247
Calcite | Level 5

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.*/

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 4665 views
  • 9 likes
  • 5 in conversation