<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: What happend when using MBCS character as macro variable name? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-happend-when-using-MBCS-character-as-macro-variable-name/m-p/956658#M373519</link>
    <description>&lt;P&gt;For me, this is a&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="7"&gt;&lt;STRONG&gt;BUG&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Such things should never be allowed, but since the introduction of VALIDVARNAME=ANY idiocy runs rampant in the SAS world.&lt;/P&gt;</description>
    <pubDate>Mon, 20 Jan 2025 11:09:29 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2025-01-20T11:09:29Z</dc:date>
    <item>
      <title>What happend when using MBCS character as macro variable name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-happend-when-using-MBCS-character-as-macro-variable-name/m-p/956638#M373514</link>
      <description>&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let software=SAS;
%let 软件=SAS;            *Chinese;
%let ソフトウェア=SAS;    *Japenese;
%let 😀=SAS;              *Emoji;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Run the code in unicode supported enviroment(&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;&amp;amp;sysencoding is utf-8&lt;/STRONG&gt;&lt;/FONT&gt;), you will see the top 3 statements will be execute without error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, when try to print the values of these variables, more suprising things comming:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;amp;=software;
SOFTWARE=SAS

%put &amp;amp;=软件;
软件

%put &amp;amp;=ソフトウェア;
ソフトウェア&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When printing values whose name are MBCS characters, names rather than values are printted.&lt;/P&gt;
&lt;P&gt;Checking sashelp.vmacro,&amp;nbsp;&lt;CODE class=" language-sas"&gt;软件&lt;/CODE&gt;&amp;nbsp;and&amp;nbsp;&lt;CODE class=" language-sas"&gt;ソフトウェア&lt;/CODE&gt;&amp;nbsp;are &lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;not found&lt;/STRONG&gt;&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ask this guy and know he use Chinese coded environment(&lt;STRONG&gt;&lt;FONT color="#339966"&gt;&amp;amp;sysencoding is euc-cn&lt;/FONT&gt;&lt;/STRONG&gt;), so I try the code in Chinese coded environment and result is different:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let software=SAS;
%let 软件=SAS;            *Chinese;
%let ソフトウェア=SAS;    *Japenese;

%put &amp;amp;=software;
SOFTWARE=SAS

%put &amp;amp;=软件;
软件=SAS

%put &amp;amp;=ソフトウェア;
ソフトウェア=SAS
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Macro variables whose name are MBCS characters behaves normal.&lt;/P&gt;
&lt;P&gt;Checking sashelp.vmacro,&amp;nbsp;&lt;CODE class=" language-sas"&gt;软件&lt;/CODE&gt;&amp;nbsp;and&amp;nbsp;&lt;CODE class=" language-sas"&gt;ソフトウェア&lt;/CODE&gt;&amp;nbsp;are &lt;FONT color="#339966"&gt;&lt;STRONG&gt;found&lt;/STRONG&gt;&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why MBCS characters can be macro variable name? How encoding impact macro variable store and parsing? Is it a bug?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 09:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-happend-when-using-MBCS-character-as-macro-variable-name/m-p/956638#M373514</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2025-01-20T09:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: What happend when using MBCS character as macro variable name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-happend-when-using-MBCS-character-as-macro-variable-name/m-p/956651#M373517</link>
      <description>&lt;P&gt;I did a test in session with single byte encoding for Polish language:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;amp;=sysencoding.;

%let software=SAS;
%let ŻÓŁĆ=sas;            *Polish;

data test;
  set sashelp.vmacro;
run;

data _null_;
  x = symget('software');
  put x=;
run;

data _null_;
  x = symget('ŻÓŁĆ');
  put x=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_0-1737368493045.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103849i4237980BF48D267B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_0-1737368493045.png" alt="yabwon_0-1737368493045.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It allows me to create macrovariable with name ŻÓŁĆ and call it with symget()&lt;/P&gt;
&lt;P&gt;Call with %put statement worked as well:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_3-1737368816181.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103852i750DF7E676DD8359/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_3-1737368816181.png" alt="yabwon_3-1737368816181.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fun fact, when you preview sashelp.vmacro, when macrovariable name is not selected you can see:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_1-1737368648422.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103850i0E521CC2FC279BEE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_1-1737368648422.png" alt="yabwon_1-1737368648422.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and when you select it:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_2-1737368689775.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103851iFED67874693B8739/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_2-1737368689775.png" alt="yabwon_2-1737368689775.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Windows 10, SAS 9.4M8, single byte session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can count me in to the audience for the answers to your questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 10:29:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-happend-when-using-MBCS-character-as-macro-variable-name/m-p/956651#M373517</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2025-01-20T10:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: What happend when using MBCS character as macro variable name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-happend-when-using-MBCS-character-as-macro-variable-name/m-p/956658#M373519</link>
      <description>&lt;P&gt;For me, this is a&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="7"&gt;&lt;STRONG&gt;BUG&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Such things should never be allowed, but since the introduction of VALIDVARNAME=ANY idiocy runs rampant in the SAS world.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 11:09:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-happend-when-using-MBCS-character-as-macro-variable-name/m-p/956658#M373519</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-01-20T11:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: What happend when using MBCS character as macro variable name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-happend-when-using-MBCS-character-as-macro-variable-name/m-p/956662#M373520</link>
      <description>&lt;P&gt;Kurt,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree with your opinion on this, it should not be allowed.&lt;/P&gt;
&lt;P&gt;But it's not only a SAS case, in some languages it's done purposely:&amp;nbsp;&lt;A href="https://docs.julialang.org/en/v1/manual/variables/#man-variables" target="_blank"&gt;https://docs.julialang.org/en/v1/manual/variables/#man-variables&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 12:51:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-happend-when-using-MBCS-character-as-macro-variable-name/m-p/956662#M373520</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2025-01-20T12:51:04Z</dc:date>
    </item>
  </channel>
</rss>

