<?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 is the purpose of the %GLOBAL statement? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/what-is-the-purpose-of-the-GLOBAL-statement/m-p/526182#M5054</link>
    <description>&lt;P&gt;If you create a macro variable inside a macro, it is not global and so it only has value inside the macro. You can't use that macro variable outside the macro. However, if you use the %global command, now the value of the macro variable can be used outside of the macro in which it was created. This might be useful if you want to pass a value from one macro to another, or&amp;nbsp;pass a macro variable value to be used in open code.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Jan 2019 20:00:07 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-01-10T20:00:07Z</dc:date>
    <item>
      <title>what is the purpose of the %GLOBAL statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/what-is-the-purpose-of-the-GLOBAL-statement/m-p/526179#M5053</link>
      <description>&lt;P&gt;I'm learning about macros for the SAS advanced programmer certification. I'm reading about the %GLOBAL and %LOCAL statements and I'm trying to decide&amp;nbsp;whether&amp;nbsp;this section is actually worth my time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Global macro varibables ("with" an actual value) will be created anyways through the %LET-statement, so why on earth would I ever be using the %GLOBAL statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 19:54:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/what-is-the-purpose-of-the-GLOBAL-statement/m-p/526179#M5053</guid>
      <dc:creator>Syntas_error</dc:creator>
      <dc:date>2019-01-10T19:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: what is the purpose of the %GLOBAL statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/what-is-the-purpose-of-the-GLOBAL-statement/m-p/526182#M5054</link>
      <description>&lt;P&gt;If you create a macro variable inside a macro, it is not global and so it only has value inside the macro. You can't use that macro variable outside the macro. However, if you use the %global command, now the value of the macro variable can be used outside of the macro in which it was created. This might be useful if you want to pass a value from one macro to another, or&amp;nbsp;pass a macro variable value to be used in open code.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 20:00:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/what-is-the-purpose-of-the-GLOBAL-statement/m-p/526182#M5054</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-01-10T20:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: what is the purpose of the %GLOBAL statement?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/what-is-the-purpose-of-the-GLOBAL-statement/m-p/526231#M5063</link>
      <description>&lt;P&gt;Macro variables have what is referred to as scope which relates to where the macro variable exists and where it receives values. This is critical to understanding what happens with macro coding especially when you have macros that call other macros. A missing %local may result in some dreadful errors, either of run time logic results or actual code failures that can be hard to trace. So you do want to know what happens with and without %local.&lt;/P&gt;
&lt;P&gt;Examine the code below and determine what the output that appears in the log should be.&lt;/P&gt;
&lt;P&gt;Then run code. Does it match your expectations.&lt;/P&gt;
&lt;PRE&gt;%macro dummy(parm);
%put Parm first used in dummy is: &amp;amp;parm.;
   %dummy2(abc);
%put Parm after calling dummy2 is &amp;amp;parm.;
%mend;
%macro dummy2(p);
   %let parm= &amp;amp;p &amp;amp;p;
   %put p in dummy2 is: &amp;amp;p.;
   %put parm in dummy2 is:&amp;amp;parm;
%mend;

%macro dummy3(parm);
%put Parm first used in dummy3 is: &amp;amp;parm.;
   %dummy4(abc);
%put Parm after calling dummy4 is &amp;amp;parm.;
%mend;
%macro dummy4(p);
   %local parm;
   %let parm= &amp;amp;p &amp;amp;p;
   %put p in dummy4 is: &amp;amp;p.;
   %put parm in dummy4 is:&amp;amp;parm;
%mend;

%dummy(pdq)
%dummy3(pdq)
&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Jan 2019 22:39:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/what-is-the-purpose-of-the-GLOBAL-statement/m-p/526231#M5063</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-01-10T22:39:26Z</dc:date>
    </item>
  </channel>
</rss>

