|
Hi Toby,
Yes, that is correct. I know about the characters BYTE(1) to BYTE(31),
which are being used for macro quoting. That apparently was the easiest way
to implement it in SAS. Otherwise extra special characters to signal the
begin and the end had to be inserted (instead of replaced), and that would
make it much more difficult for the programmers of SAS to realize macro
quoting. Anyway, my question actually is; why are those masking characters
ignored with %EVAL and %SUBSTR? Are they ignored as well with implcit
evaluation of conditions (after %IF)?
Regards - Jim (from home, without SAs again).
On Fri, 2 Jul 2004 10:32:24 -0500, Dunn, Toby <tdunn@TEA.STATE.TX.US> wrote:
>I should have said,
>
>The following should explain part of the problem. And actually explains
>why
>
>%let a = %str( );
>%let b = %str( );
>
>%put %eval(&a = &b); will return as true (1).
>
>And why
>
>%put %eval(%length(&a) = %length(&b)); will return a false (0);
>
>Toby Dunn
>
>
>-----Original Message-----
>From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
>Dunn, Toby
>Sent: Friday, July 02, 2004 10:29 AM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: "Missing" macro values, was: Re: Macro Variable Problem
>
>Jim,
>The following should explain part of the problem. And actually explains
>why %let a = %str( );
>%let b = %str( );
>
>%put %eval(&a = &b); will return as true (1).
>
>
>
>How Macro Quoting Works
>
>When the macro processor masks a text string, it masks special
>characters and mnemonics within the coding scheme, and prefixes and
>suffixes the string with a hexadecimal character, called a delta
>character. The prefix character marks the beginning of the string and
>also indicates what type of macro quoting is to be applied to the
>string. The suffix character marks the end of the string. The prefix and
>suffix characters preserve any leading and trailing blanks contained by
>the string. The hexadecimal characters used to mask special characters
>and mnemonics and those used for the prefix and suffix characters may
>vary and are not portable.
>
>There are more hexadecimal combinations possible in each byte than are
>needed to represent the symbols on a keyboard. Therefore, when a macro
>quoting function recognizes an item to be masked, the macro processor
>uses a previously unused hexadecimal combination for the prefix and
>suffix characters.
>
>Macro functions, such as %EVAL and %SUBSTR, ignore the prefix and suffix
>characters. Therefore, the prefix and suffix characters do not affect
>comparisons.
>
>When the macro processor is finished with a macro quoted text string, it
>removes the macro quoting-coded substitute characters and replaces them
>with the original characters. The unmasked characters are passed on to
>the rest of the system. Sometimes you might see a message about this
>unmasking, as in the following example:
>
>/* Turn on SYMBOLGEN so you can see the messages about unquoting. */
>options symbolgen;
>
>/* Assign a value to EXAMPLE that contains several special */
>/* characters and a mnemonic. */
>%let example = %nrbquote( 1 + 1 = 3 Today's Test and More );
>
>%put *&example*;
>
>When this program is submitted, the following appears in the SAS log:
>
>SYMBOLGEN: Macro variable EXAMPLE resolves to 1 + 1 = 3 Today's
> Test and More
>SYMBOLGEN: Some characters in the above value which were subject
> to macro quoting have been unquoted for printing.
>* 1 + 1 = 3 Today's Test and More *
>
>As you can see, the leading and trailing blanks and special characters
>were retained in the variable's value. While the macro processor was
>working with the string, the string actually contained coded characters
>that were substituted for the "real" characters. The substitute
>characters included coded characters to represent the start and end of
>the string. This preserved the leading and trailing blanks. Characters
>were also substituted for the special characters + , = , and ' , and the
>mnemonic AND . When the macro finished processing and the characters
>were passed to the rest of SAS, the coding was removed and the real
>characters were replaced.
>
>
>Should explain the quoting and unquoting problem in the code you gave us
>with symbolgen turned on.
>
[.........]
|