Macro Functions |
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 might 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 Macro Quoting.
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 might 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 unmasks the value of TESTVAL.
%let val = aaa; %let testval = %str(%'&val%'); data _null_; val = %unquote(&testval); put 'VAL =' val; run;
This program prints the following to the SAS log:
VAL=aaa
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.