Previous Page | Next Page

Macro Functions

%UNQUOTE Function



During macro execution, unmasks all special characters and mnemonic operators for a value.
Type: Macro function
See also:

%BQUOTE and %NRBQUOTE Functions

%NRBQUOTE Function

%NRQUOTE Function

%NRSTR Function

%QUOTE and %NRQUOTE Functions

%STR and %NRSTR Functions

%SUPERQ Function


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


Example 1: Using %UNQUOTE to Unmask Values

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

Previous Page | Next Page | Top of Page