In a very unique situation, I see a guy's program and he use Chinese character as macro variable name, it supriesed me because I used to think the naming rules of macro variable is the same with dataset variable. But the code can really run without syntax error:
%let software=SAS;
%let 软件=SAS; *Chinese;
%let ソフトウェア=SAS; *Japenese;
%let 😀=SAS; *Emoji;
Run the code in unicode supported enviroment(&sysencoding is utf-8), you will see the top 3 statements will be execute without error.
However, when try to print the values of these variables, more suprising things comming:
%put &=software;
SOFTWARE=SAS
%put &=软件;
软件
%put &=ソフトウェア;
ソフトウェア
When printing values whose name are MBCS characters, names rather than values are printted.
Checking sashelp.vmacro, 软件 and ソフトウェア are not found.
I ask this guy and know he use Chinese coded environment(&sysencoding is euc-cn), so I try the code in Chinese coded environment and result is different:
%let software=SAS;
%let 软件=SAS; *Chinese;
%let ソフトウェア=SAS; *Japenese;
%put &=software;
SOFTWARE=SAS
%put &=软件;
软件=SAS
%put &=ソフトウェア;
ソフトウェア=SAS
Macro variables whose name are MBCS characters behaves normal.
Checking sashelp.vmacro, 软件 and ソフトウェア are found.
I am using SAS 9.4 M8 on Win11. After multiple attempts, I confirm that both two-byte and three-byte characters can be used as macro variable names.
Why MBCS characters can be macro variable name? How encoding impact macro variable store and parsing? Is it a bug?
... View more