<?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: Is initialization required for creating Macro variables in SAS? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Is-initialization-required-for-creating-Macro-variables-in-SAS/m-p/737938#M28833</link>
    <description>&lt;P&gt;Adding to what Tom has said, you only have to first initialize the macro variable if you want to make it global (with the &lt;EM&gt;%global&lt;/EM&gt; statement):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%GLOBAL myvar;
%let myvar = xxx;&lt;/PRE&gt;&lt;P&gt;Otherwise, you don't have to.&lt;/P&gt;</description>
    <pubDate>Thu, 29 Apr 2021 15:03:38 GMT</pubDate>
    <dc:creator>SAS-Nutzer</dc:creator>
    <dc:date>2021-04-29T15:03:38Z</dc:date>
    <item>
      <title>Is initialization required for creating Macro variables in SAS?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Is-initialization-required-for-creating-Macro-variables-in-SAS/m-p/737800#M28827</link>
      <description>&lt;P&gt;I know with a character variable in SAS, you want to define the length first otherwise it'll have the length of the first value. I wonder if this is something that'll affect macro vars as well? I'm just talking about normal variables like a counter in a do loop. I'm not talking about the dynamic macro vars which is too advanced for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 03:14:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Is-initialization-required-for-creating-Macro-variables-in-SAS/m-p/737800#M28827</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2021-04-29T03:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Is initialization required for creating Macro variables in SAS?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Is-initialization-required-for-creating-Macro-variables-in-SAS/m-p/737804#M28828</link>
      <description>&lt;P&gt;Macro variable do not have a type (everything is text to the macro processor) and are not fixed length. So there is no need to "define" them in the sense you mean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But they do have scope.&amp;nbsp; You will discovery the impact of this when you work with actual macro definition and not just macro variables.&amp;nbsp; If you create a macro variable inside a running macro that has not been defined before then will be created local to that macro, which means it will disappear when the macro finishes running.&amp;nbsp; (Like WORK dataset disappear when your SAS session ends).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you might want to &lt;STRONG&gt;initialize&lt;/STRONG&gt; a macro variable to a default value in case the code you are using to calculate and assign a value does not run.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The place I normally see this being needed is when using SQL to create the macro variables and the query does not return any results.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
%let over20=NONE;
select name into :over20 separated by ' '
  from sashelp.class
  where age &amp;gt; 20
;
quit;
%put &amp;amp;=over20;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;833   proc sql noprint;
834   %let over20=NONE;
835   select name into :over20 separated by ' '
836     from sashelp.class
837     where age &amp;gt; 20
838   ;
NOTE: No rows were selected.
839   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.04 seconds
      cpu time            0.00 seconds


840   %put &amp;amp;=over20;
OVER20=NONE
&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Apr 2021 04:06:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Is-initialization-required-for-creating-Macro-variables-in-SAS/m-p/737804#M28828</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-29T04:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: Is initialization required for creating Macro variables in SAS?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Is-initialization-required-for-creating-Macro-variables-in-SAS/m-p/737805#M28829</link>
      <description>&lt;P&gt;Macro variable length is set in system options.&lt;/P&gt;
&lt;P&gt;MVARSIZE sets the maximum size for a macro variable. The default is 65534 characters. You can set the option greater but if you need to you probably should reconsider what the heck you are stuffing into macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This interacts with the option MSYMTABMAX for keeping macro variables in memory. If the length of macro variables exceeds this setting then the values start getting written/read to disk and can affect performance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want to check the documentation for your operating system as each has peculiarites.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 04:07:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Is-initialization-required-for-creating-Macro-variables-in-SAS/m-p/737805#M28829</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-29T04:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Is initialization required for creating Macro variables in SAS?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Is-initialization-required-for-creating-Macro-variables-in-SAS/m-p/737814#M28831</link>
      <description>&lt;P&gt;According to the documentation of&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/mcrolref/n1eqbq8qk42fz5n14v229azkoil6.htm" target="_blank" rel="noopener"&gt;MVARSIZE=&lt;/A&gt;, the maximum value is still 65534, although units of M and G are syntactically allowed.&lt;/P&gt;
&lt;P&gt;Also see this:&lt;/P&gt;
&lt;PRE&gt; 73         options mvarsize=65535;
                    ________
                    18
 ERROR 18-12: Optionswert für SAS-Option MVARSIZE muss zwischen 0 und 65534 sein.
&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Apr 2021 07:01:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Is-initialization-required-for-creating-Macro-variables-in-SAS/m-p/737814#M28831</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-29T07:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: Is initialization required for creating Macro variables in SAS?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Is-initialization-required-for-creating-Macro-variables-in-SAS/m-p/737938#M28833</link>
      <description>&lt;P&gt;Adding to what Tom has said, you only have to first initialize the macro variable if you want to make it global (with the &lt;EM&gt;%global&lt;/EM&gt; statement):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%GLOBAL myvar;
%let myvar = xxx;&lt;/PRE&gt;&lt;P&gt;Otherwise, you don't have to.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 15:03:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Is-initialization-required-for-creating-Macro-variables-in-SAS/m-p/737938#M28833</guid>
      <dc:creator>SAS-Nutzer</dc:creator>
      <dc:date>2021-04-29T15:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: Is initialization required for creating Macro variables in SAS?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Is-initialization-required-for-creating-Macro-variables-in-SAS/m-p/737998#M28849</link>
      <description>Thank you! That was a very thorough explanation!</description>
      <pubDate>Thu, 29 Apr 2021 19:40:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Is-initialization-required-for-creating-Macro-variables-in-SAS/m-p/737998#M28849</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2021-04-29T19:40:18Z</dc:date>
    </item>
  </channel>
</rss>

