<?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: Call Symputx is not creating macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959848#M374460</link>
    <description>&lt;PRE&gt;&lt;U&gt;&lt;STRONG&gt;call symputx("%nrquote(&amp;amp;name.)", dsname,'G');&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;STRONG&gt;&lt;SPAN class="xisDoc-keyword"&gt;CALL SYMPUTX&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;STRONG&gt;(&lt;EM class="xisDoc-userSuppliedValue"&gt;macro-variable&lt;/EM&gt;,&lt;EM class="xisDoc-userSuppliedValue"&gt;value&lt;/EM&gt;&lt;SPAN class="xisDoc-optional"&gt;&amp;lt;,&lt;EM class="xisDoc-userSuppliedValue"&gt;symbol-table&lt;/EM&gt;&amp;gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;STRONG&gt;);&lt;/STRONG&gt;&lt;U&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Use the SYMPUTX third parameter to define the symbol-table for the variable being created.&amp;nbsp; 'G' for global.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Feb 2025 21:53:08 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2025-02-20T21:53:08Z</dc:date>
    <item>
      <title>Call Symputx is not creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959840#M374456</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Please let me know what am I missing here, Macro ABC and DEF are not resolving, call symputx is not creating these macro variables. I tried with &amp;amp; without masking functions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Issue:&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference ABC not resolved.&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference DEF not resolved.&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;%macro get(name=);
data _null_;
set _x;
.....
....
....
dsname =&amp;nbsp;strip(upcase(scan(strip(reverse(ds)), 1, '.')));
&lt;U&gt;&lt;STRONG&gt;call symputx("nrquote(&amp;amp;name.)", dsname );&lt;BR /&gt;&lt;/STRONG&gt;&lt;/U&gt;run;
%mend get;

%get(name=ABC);
%get(name=DEF);&lt;BR /&gt;&lt;BR /&gt;%put ABC=&amp;amp;ABC;&lt;BR /&gt;%put DEF=&amp;amp;DEF;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 20 Feb 2025 21:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959840#M374456</guid>
      <dc:creator>Rain_28</dc:creator>
      <dc:date>2025-02-20T21:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: Call Symputx is not creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959842#M374457</link>
      <description>&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/mcrolref/1.0/n0i4icf2nv7wu7n1lm4wf1epykfh.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/mcrolref/1.0/n0i4icf2nv7wu7n1lm4wf1epykfh.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;use a %GLOBAL statement to give the variables global scope. By default, the scope is local.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 21:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959842#M374457</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2025-02-20T21:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Call Symputx is not creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959845#M374458</link>
      <description>Isn't Call Symputx creates a global macro variable? Available through out the program? That's what I understood reading the papers.&lt;BR /&gt;&lt;BR /&gt;Added %global and it worked, thanks!</description>
      <pubDate>Thu, 20 Feb 2025 21:49:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959845#M374458</guid>
      <dc:creator>Rain_28</dc:creator>
      <dc:date>2025-02-20T21:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Call Symputx is not creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959847#M374459</link>
      <description>&lt;P&gt;How do you know they weren't created?&amp;nbsp; &lt;STRONG&gt;You didn't check them until after the macro ended.&lt;/STRONG&gt;&amp;nbsp; Once a macro stops running any local macro variables (symbols) are gone.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And why do you have the %NRQUOTE() function???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the macro variables created in the GLOBAL symbol table you can ask CALL SYMPUTX() to do that for you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputx("&amp;amp;name", dsname, 'g' );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But it might be more flexible if you had the macro make the macro variable global.&amp;nbsp; That way you could do it only when the macro variable did not already exist in the calling environment.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro get(name=);
%if not %symexist(&amp;amp;name) %then %global &amp;amp;name;
....
call symputx("&amp;amp;name", dsname );
...
%mend get;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 21:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959847#M374459</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-02-20T21:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Call Symputx is not creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959848#M374460</link>
      <description>&lt;PRE&gt;&lt;U&gt;&lt;STRONG&gt;call symputx("%nrquote(&amp;amp;name.)", dsname,'G');&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;STRONG&gt;&lt;SPAN class="xisDoc-keyword"&gt;CALL SYMPUTX&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;STRONG&gt;(&lt;EM class="xisDoc-userSuppliedValue"&gt;macro-variable&lt;/EM&gt;,&lt;EM class="xisDoc-userSuppliedValue"&gt;value&lt;/EM&gt;&lt;SPAN class="xisDoc-optional"&gt;&amp;lt;,&lt;EM class="xisDoc-userSuppliedValue"&gt;symbol-table&lt;/EM&gt;&amp;gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;STRONG&gt;);&lt;/STRONG&gt;&lt;U&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Use the SYMPUTX third parameter to define the symbol-table for the variable being created.&amp;nbsp; 'G' for global.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 21:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959848#M374460</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2025-02-20T21:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: Call Symputx is not creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959852#M374463</link>
      <description>&lt;P&gt;&lt;SPAN&gt;And why do you have the %NRQUOTE() function??? -----&amp;gt;&amp;nbsp;&lt;/SPAN&gt;I thought may be the macro variable resolution has something to do with the issue, so was trying out!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Below highlighted statement got me that this macro variable is available globally.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rain_28_0-1740088717872.png" style="width: 733px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104817i88F1A65AED788540/image-dimensions/733x121?v=v2" width="733" height="121" role="button" title="Rain_28_0-1740088717872.png" alt="Rain_28_0-1740088717872.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Didn't come across 'g' option puts macro variable in global symbol table. Glad to learn that, very helpful.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 22:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959852#M374463</guid>
      <dc:creator>Rain_28</dc:creator>
      <dc:date>2025-02-20T22:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Call Symputx is not creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959869#M374472</link>
      <description>&lt;P&gt;Where did get that description?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2025 01:12:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959869#M374472</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-02-21T01:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: Call Symputx is not creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959965#M374490</link>
      <description>&lt;A href="https://www.lexjansen.com/pharmasug-cn/2017/CC/PharmaSUG-China-2017-CC01.pdf" target="_blank"&gt;https://www.lexjansen.com/pharmasug-cn/2017/CC/PharmaSUG-China-2017-CC01.pdf&lt;/A&gt;</description>
      <pubDate>Fri, 21 Feb 2025 21:13:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959965#M374490</guid>
      <dc:creator>Rain_28</dc:creator>
      <dc:date>2025-02-21T21:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Call Symputx is not creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959970#M374492</link>
      <description>&lt;P&gt;That paper uses the word "can be accessed globally" in a less than precise way. Better: "can optionally be accessed globally." You are better off looking at SAS documentation, which is freely accessible on the web. As others have pointed out, using the 'G' parameter in SYMPUTX is an alternative to the %GLOBAL statement and is the easier solution. I suppose it depends on your programming style. If you want your macro to state up front what the global variables are, use %GLOBAL. If you want to specify it on the fly, particularly with macro variable names that are manufactured on the fly, use the 'G' parameter in SYMPUTX. When I was writing big macros, I liked to put %LOCAL and %GLOBAL statements up front listing all my macro variables, but that is certainly not required.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2025 21:51:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959970#M374492</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2025-02-21T21:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Call Symputx is not creating macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959971#M374493</link>
      <description>Thanks!</description>
      <pubDate>Fri, 21 Feb 2025 22:15:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Symputx-is-not-creating-macro-variable/m-p/959971#M374493</guid>
      <dc:creator>Rain_28</dc:creator>
      <dc:date>2025-02-21T22:15:56Z</dc:date>
    </item>
  </channel>
</rss>

