Sample 25076: Resolve a macro variable within single quotation marks
The sample code on the Full Code tab illustrates how to resolve a macro variable within single quotation marks.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
The sample code below illustrates how to resolve a macro variable within single quotation marks.
%let name=Fred;
data _null_;
put %unquote(%str(%'NAME: &name%'));
run;
/** Another possible solution is shown below **/
data _null;
put %unquote(%nrbquote('NAME: &name'));
run;
/** Starting in SAS 9.4, you can use the %TSLIT macro. For example: **/
%let name=Fred;
data _null_;
put %tslit(NAME: &name);
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Output from log
NAME: Fred
Macro variables can be resolved between single quotation marks using the %STR function inside an %UNQUOTE function. The %UNQUOTE function is recommended to remove any remaining macro delta characters created by the %STR function.
Type: | Sample |
Topic: | SAS Reference ==> Macro
|
Date Modified: | 2010-04-20 10:49:08 |
Date Created: | 2005-01-26 16:17:19 |
Operating System and Release Information
SAS System | Base SAS | OpenVMS Alpha | 9 TS M0 | |
Tru64 UNIX | 9 TS M0 | |
Linux | 9 TS M0 | |
64-bit Enabled Solaris | 9 TS M0 | |
HP-UX IPF | 9 TS M0 | |
64-bit Enabled HP-UX | 9 TS M0 | |
64-bit Enabled AIX | 9 TS M0 | |
Microsoft Windows XP Professional | 9 TS M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9 TS M0 | |
Microsoft Windows Server 2003 Standard Edition | 9 TS M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9 TS M0 | |
Microsoft Windows NT Workstation | 9 TS M0 | |
Microsoft Windows 2000 Professional | 9 TS M0 | |
Microsoft Windows 2000 Server | 9 TS M0 | |
Microsoft Windows 2000 Advanced Server | 9 TS M0 | |
Microsoft Windows 2000 Datacenter Server | 9 TS M0 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9 TS M0 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9 TS M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9 TS M0 | |
z/OS | 9 TS M0 | |