<?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: Assign a macro variable inside a macro. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assign-a-macro-variable-inside-a-macro/m-p/13272#M1550</link>
    <description>Assigning av macro variable inside a macro creates a variable that is local to the macro. &lt;BR /&gt;
To be able to refer to it outside the macro you need to add a %global before the assignment.&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
    <pubDate>Fri, 06 Nov 2009 11:18:14 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2009-11-06T11:18:14Z</dc:date>
    <item>
      <title>Assign a macro variable inside a macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-a-macro-variable-inside-a-macro/m-p/13271#M1549</link>
      <description>What is wrong with this stupid example:&lt;BR /&gt;
&lt;BR /&gt;
%macro test;&lt;BR /&gt;
%let x=10;&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
%test;&lt;BR /&gt;
%put &amp;amp;x;&lt;BR /&gt;
&lt;BR /&gt;
In the log I get (after the code listing):&lt;BR /&gt;
&lt;BR /&gt;
WARNING: Apparent symbolic reference X not resolved&lt;BR /&gt;
&amp;amp;x&lt;BR /&gt;
&lt;BR /&gt;
I expected to get the value 10.&lt;BR /&gt;
&lt;BR /&gt;
Don't ask me why I want to assign a macro variable inside a macro.</description>
      <pubDate>Fri, 06 Nov 2009 10:32:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-a-macro-variable-inside-a-macro/m-p/13271#M1549</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-11-06T10:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: Assign a macro variable inside a macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-a-macro-variable-inside-a-macro/m-p/13272#M1550</link>
      <description>Assigning av macro variable inside a macro creates a variable that is local to the macro. &lt;BR /&gt;
To be able to refer to it outside the macro you need to add a %global before the assignment.&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Fri, 06 Nov 2009 11:18:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-a-macro-variable-inside-a-macro/m-p/13272#M1550</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-11-06T11:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Assign a macro variable inside a macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-a-macro-variable-inside-a-macro/m-p/13273#M1551</link>
      <description>Some useful reading from the SAS support  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website for you to consider.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
SAS  Macro Language: Reference - Scopes of Macro Variables&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002047080.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002047080.htm&lt;/A&gt;</description>
      <pubDate>Fri, 06 Nov 2009 13:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-a-macro-variable-inside-a-macro/m-p/13273#M1551</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-11-06T13:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Assign a macro variable inside a macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-a-macro-variable-inside-a-macro/m-p/13274#M1552</link>
      <description>** SAS forum burp - duplicate removed **</description>
      <pubDate>Fri, 06 Nov 2009 13:13:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-a-macro-variable-inside-a-macro/m-p/13274#M1552</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-11-06T13:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Assign a macro variable inside a macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-a-macro-variable-inside-a-macro/m-p/13275#M1553</link>
      <description>If you move the %put statement inside the macro, everything works.&lt;BR /&gt;
&lt;BR /&gt;
Another responder has explained how %global also fixed the problem, but I would recommend instead of %global, you do all macro commands involving your macro variables INSIDE the macro.</description>
      <pubDate>Fri, 06 Nov 2009 15:36:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-a-macro-variable-inside-a-macro/m-p/13275#M1553</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2009-11-06T15:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: Assign a macro variable inside a macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-a-macro-variable-inside-a-macro/m-p/13276#M1554</link>
      <description>Exactly.  And there are some good examples of how it works in the doc link that Scott posted, above.</description>
      <pubDate>Tue, 01 Dec 2009 14:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-a-macro-variable-inside-a-macro/m-p/13276#M1554</guid>
      <dc:creator>PatrickG</dc:creator>
      <dc:date>2009-12-01T14:18:34Z</dc:date>
    </item>
  </channel>
</rss>

