Usage Note 36916: Take caution when assigning hexadecimal values to macro variables
You need to take caution when assigning hexadecimal values or values containing unprintable characters to a macro variable because not all hexadecimal values can be preserved.
The SAS Macro Facility uses certain hexadecimal values within various macro quoting functions. Therefore, the SAS Macro Facility does not support all hexadecimal values being passed to macro variables. The specific hexadecimal values used for the quoting functions are proprietary and are not published.
Following is an example to show a hexadecimal value stored in a character variable that contains some unprintable characters that will not have all characters preserverd when passed to a macro variable. In a subsequent DATA step when a new variable is assigned to the macro variable and displayed to the log with the $HEXw. format, the original hexadecimal value is not preserved. This example uses character representation based on ASCII code assignments.
data _null_;
var='00093230'x;
call symput('macvar',var);
run;
data _null_;
newvar="&macvar";
put newvar= $hex8.;
run;
The result of the put statement to the log will show: newvar=093230
Below is a method that can be used to preserve the hexadecimal value in the macro variable by using the PUT function with the $HEX8. format at the time of creating the macro variable with CALL SYMPUT. When assigning the macro variable in subsequent steps you must surround the macro variable with double quotes and immediately follow the closing double quote with an X so the value is represented as a hexadecimal value. When displaying the results of the newvar variable to the log the original value is preserved.
data _null_;
var='00093230'x;
call symput('macvar',put(var,$hex8.));
run;
data _null_;
newvar="&macvar"x;
put newvar= $hex8.;
run;
Operating System and Release Information
SAS System | Base SAS | Microsoft® Windows® for x64 | | |
Microsoft Windows XP 64-bit Edition | | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | | |
OpenVMS VAX | | |
z/OS | | |
OS/2 | | |
Microsoft Windows 95/98 | | |
Microsoft Windows 2000 Advanced Server | | |
Microsoft Windows 2000 Datacenter Server | | |
Microsoft Windows 2000 Server | | |
Microsoft Windows 2000 Professional | | |
Microsoft Windows NT Workstation | | |
Microsoft Windows Server 2003 Datacenter Edition | | |
Microsoft Windows Server 2003 Enterprise Edition | | |
Microsoft Windows Server 2003 Standard Edition | | |
Microsoft Windows Server 2008 | | |
Microsoft Windows XP Professional | | |
Windows Millennium Edition (Me) | | |
Windows Vista | | |
64-bit Enabled AIX | | |
64-bit Enabled HP-UX | | |
64-bit Enabled Solaris | | |
ABI+ for Intel Architecture | | |
AIX | | |
HP-UX | | |
HP-UX IPF | | |
IRIX | | |
Linux | | |
Linux for x64 | | |
Linux on Itanium | | |
OpenVMS Alpha | | |
OpenVMS on HP Integrity | | |
Solaris | | |
Solaris for x64 | | |
Tru64 UNIX | | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
Not all hexadecimal values can be preserved when assigning a hexadecimal value or a value containing unprintable characters to a macro variable.
Type: | Usage Note |
Priority: | |
Topic: | SAS Reference ==> DATA Step Common Programming Tasks ==> Conditional Processing Common Programming Tasks ==> Working with Character Data Common Programming Tasks
|
Date Modified: | 2009-08-24 14:11:23 |
Date Created: | 2009-08-18 13:44:54 |