Chapter Contents |
Previous |
Next |
%UNQUOTE |
Type: | Macro function | |||||||
See also: |
|
Syntax | |
Details | |
Example | |
Using %UNQUOTE to Unmask Values |
Syntax |
%UNQUOTE (character string | text expression) |
Details |
The %UNQUOTE function unmasks a value so that special characters that it may contain are interpreted as macro language elements instead of as text. The most important effect of %UNQUOTE is to restore normal tokenization of a value whose tokenization was altered by a previous macro quoting function. %UNQUOTE takes effect during macro execution.
For more information, see Chapter 7 in SAS Macro Language: Reference.
Example |
This example demonstrates a problem that can arise when the value of a macro variable is assigned using a macro quoting function and then the variable is referenced in a later DATA step. If the value is not unmasked before it reaches the SAS compiler, the DATA step does not compile correctly and it produces error messages. Although several macro functions automatically unmask values, a variable may not be processed by one of those functions.
The following program generates error messages in the SAS log because the value of TESTVAL is still masked when it reaches the SAS compiler.
%let val = aaa; %let testval = %str(%'&val%'); data _null_; val = &testval; put 'VAL =' val; run;
This version of the program runs correctly because %UNQUOTE explicitly unmasks the value of TESTVAL.
%let val = aaa; %let testval = %str(%'&val%'); data _null_; val = %unquote(&testval); put 'VAL =' val; run;
This program prints this to the SAS log:
VAL=aaa
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.