<?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 Question for SYMPUTX from SAS HELP CENTER in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Question-for-SYMPUTX-from-SAS-HELP-CENTER/m-p/937018#M42116</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following example is from the SAS Help Center:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let x=1;
%let items=2;
%macro test(val);

data _null_;
 call symputx('items', ' leading and trailing blanks removed ', 'L');
 call symputx('  x   ', 123.456);
run;

%put local items &amp;amp;items;
%mend test;
  
%test(100)
      
%put items=!&amp;amp;items!;
%put x=!&amp;amp;x!;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Question: Why is there a parameter val used for the macro test? What does that 100 do when used for val? I couldn't tell from the log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jul 2024 15:59:57 GMT</pubDate>
    <dc:creator>cosmid</dc:creator>
    <dc:date>2024-07-24T15:59:57Z</dc:date>
    <item>
      <title>Question for SYMPUTX from SAS HELP CENTER</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Question-for-SYMPUTX-from-SAS-HELP-CENTER/m-p/937018#M42116</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following example is from the SAS Help Center:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let x=1;
%let items=2;
%macro test(val);

data _null_;
 call symputx('items', ' leading and trailing blanks removed ', 'L');
 call symputx('  x   ', 123.456);
run;

%put local items &amp;amp;items;
%mend test;
  
%test(100)
      
%put items=!&amp;amp;items!;
%put x=!&amp;amp;x!;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Question: Why is there a parameter val used for the macro test? What does that 100 do when used for val? I couldn't tell from the log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 15:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Question-for-SYMPUTX-from-SAS-HELP-CENTER/m-p/937018#M42116</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2024-07-24T15:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Question for SYMPUTX from SAS HELP CENTER</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Question-for-SYMPUTX-from-SAS-HELP-CENTER/m-p/937021#M42117</link>
      <description>&lt;P&gt;Good question!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of the strange things about both CALL SYMPUTX() and CALL SYMPUT() is which symbol table it will use to create a new symbol (what most people normally call macro variables).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The strange thing is that SAS does not always create a symbol table for every running macro.&amp;nbsp; Macros that do not have any local macro variables do not get a symbol table defined.&amp;nbsp; In which case the new macro variable will be created in the next higher symbol table.&amp;nbsp; Which could be the local symbol table of the calling macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By adding a parameter to the macro definition they insured that the macro will have at least one local symbol so that there will be a local symbol table created when it runs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this example.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro nosymtable;
* This macro will have no symbol table; 
data _null_;
  call symputx('nosymboltable','xxx');
run;
%mend nosymtable;

%macro makemvar(mvar,value);
data _null_;
  call symputx("&amp;amp;mvar","&amp;amp;value");
run;
%nosymtable;
%put _user_;
%mend makemvar;

%makemvar(test2,yyy);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What symbol table has the value xxx in the macro variable&amp;nbsp;nosymboltable?&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;MAKEMVAR MVAR test2
MAKEMVAR NOSYMBOLTABLE xxx
MAKEMVAR TEST2 yyy
MAKEMVAR VALUE yyy
GLOBAL SQLEXITCODE 0
GLOBAL SQLOBS 1
GLOBAL SQLOOPS 136
GLOBAL SQLRC 0
GLOBAL SQLXOBS 0
GLOBAL SQLXOPENERRS 0
GLOBAL SYS_SQL_IP_ALL -1
GLOBAL SYS_SQL_IP_STMT
&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;</description>
      <pubDate>Wed, 24 Jul 2024 16:17:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Question-for-SYMPUTX-from-SAS-HELP-CENTER/m-p/937021#M42117</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-07-24T16:17:45Z</dc:date>
    </item>
  </channel>
</rss>

