Chapter Contents

Previous

Next
%UNQUOTE

%UNQUOTE



During macro execution, unmasks all special characters and mnemonic operators for a value

Type: Macro function
See also:
%BQUOTE and %NRBQUOTE
%NRBQUOTE
%NRQUOTE
%NRSTR
%QUOTE and %NRQUOTE
%STR and %NRSTR
%SUPERQ


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

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 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.