DATA Step, Macro, Functions and more

macro quoting

Reply
N/A
Posts: 0

macro quoting

%let names=%nrstr(O%'DONOVAN&O%'HARA&O%'MALLEY);
%let name3=%qscan(&names,3);
%put WITH NRSTR Quoting Function NAMES=&names;
%put WITH NRSTR Quoting Function NAME 3 is: &name3;

What is the equivalent code is sas with %nrbquote in the previous code.

i wrote the code but it throws warning,

%let names=%nrbquote(O'DONOVAN&O'HARA&O'MALLEY);
%let name3=%qscan(&names,3);
%put WITH NRSTR Quoting Function NAMES=&names;
%put WITH NRSTR Quoting Function NAME 3 is: &name3;

Thanks in advance.
murali
Frequent Contributor
Posts: 87

Re: macro quoting

Posted in reply to deleted_user
I do think you can not prevent the warnings when using the %nrbquote function.
From the Online Doc on the %nrbquote function I read the following:
If the argument of the %NRBQUOTE function contains an unresolvable macro variable reference or macro invocation, the macro processor issues a warning message before it masks the ampersand or percent sign (assuming the SERROR or MERROR system option, described in is in effect). To suppress the message for unresolved macro variables, use the %SUPERQ function (discussed later in this section) instead.

So you may want to try the %superq function of which in the documentation is indicated:
Because %SUPERQ does not attempt any resolution of its argument, the macro processor does not issue any warning messages that a macro variable reference or a macro invocation has not been resolved. Therefore, even when the %NRBQUOTE function enables the program to work correctly, you can use the %SUPERQ function to eliminate unwanted warning messages from the SAS log.

I hope this helps. Message was edited by: eomred
N/A
Posts: 0

Re: macro quoting

Posted in reply to deleted_user
There isnt any simply because %NrStr is a compile time Quoting function while %NrBQuote is a Execution time quoting function. Hence they mask certain characters at different times in the process.

%let names=%nrstr(O%'DONOVAN&O%'HARA&O%'MALLEY);
Is a compile time statement

%put WITH NRSTR Quoting Function NAMES=&names;
Is an execution time statement.

The first rule of macro quoting is 'DONT', if you think you do need it then rethink your approach. If you find you still need it make darn sure you know what you are quoting, why you are quoting it and when you want it quoted.
Ask a Question
Discussion stats
  • 2 replies
  • 134 views
  • 0 likes
  • 2 in conversation