<?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: How to dynamically add macro variables to %LOCAL statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129808#M26501</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@Astounding,&lt;BR /&gt;I just has given you to the documentational links a I have done solving this kind of issue for many years...&amp;nbsp; Nearly about some 30 of them,&lt;BR /&gt;I was supporting SAS in a former big organization connecting Windows Unix and Mainframe together freeing the users/analists of this kind of issues.&lt;/P&gt;&lt;P&gt;All kind of macro issues are burned into my fingers. I referred KSharp as recognizing the value of his statement.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;As said and documented the local definition is not needed/ This is tested and used many times. You can test it by removing it, and it still will run.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Aside the scope also macro quiting can be very challenging. Wanting to combine it with SAS/connect or SQL pass-thru is giving a lot other nice things. As a nice&amp;nbsp; sample I put on my personal site: &lt;A href="http://metier.jakarman.nl/smpl111.html" title="http://metier.jakarman.nl/smpl111.html"&gt;Sample Securing Business keys and passwords &lt;/A&gt;(%keypsw) &lt;BR /&gt;It solves the issue of eliminating key/psw in code. By the way this macro knowledge is part of SAS -advanced. After all years I started to collect some of those certifications. You can find me on linkedin as you probably wish.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Jul 2013 20:13:14 GMT</pubDate>
    <dc:creator>jakarman</dc:creator>
    <dc:date>2013-07-11T20:13:14Z</dc:date>
    <item>
      <title>How to dynamically add macro variables to %LOCAL statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129797#M26490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Suppose I am creating a bunch of macro variables, and the number of macro variables can change depending on the input data set.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select count(distinct salesman) into :nsales from dataset;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct salesman into :sales1-:sales%left(&amp;amp;nsales) from dataset;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there are 4 salesmen in the dataset, I get 4 macro variables. If there are 5 salesmen in the dataset, I get 5 macro variables. And so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like all the macro variables thus created to be in a %LOCAL statement. Is there an easy way to do this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2013 18:47:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129797#M26490</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2013-07-09T18:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically add macro variables to %LOCAL statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129798#M26491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not too difficult ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're allowed to specify a macro variable name that will resolve, such as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%local sales&amp;amp;i;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you could run with this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%local i;&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;nsales;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %local sales&amp;amp;i;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The tricky part is that you can actually insert this code between your SELECT statements.&amp;nbsp; Each SELECT statement runs immediately, and the %DO loop also runs immediately.&amp;nbsp; So the statements would all run in the proper order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2013 19:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129798#M26491</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-07-09T19:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically add macro variables to %LOCAL statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129799#M26492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It might be easier to use CALL SYMPUT&lt;STRONG&gt;X&lt;/STRONG&gt; and specify the scope than to do all that looping.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2013 20:09:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129799#M26492</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-07-09T20:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically add macro variables to %LOCAL statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129800#M26493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or to create a single macro variable and loop through it in your macro list as I imagine you're doing a %do loop somewhere else using the counter and the macro variables created. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2013 20:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129800#M26493</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-07-09T20:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically add macro variables to %LOCAL statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129801#M26494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Those macro variables would be local, if you keep it in a macro, and those macro vaiables are not defined before.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jul 2013 01:13:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129801#M26494</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2013-07-10T01:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically add macro variables to %LOCAL statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129802#M26495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is a automatic macro variable called sysmaxlong which has a values of 2147483647, this can be used to automatically generate n number of macro variables. And since we are generating the macro variables within the macro, they all will be local macro variables. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please try the below code;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro test();&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select name into :name1-:name&lt;STRONG&gt;&amp;amp;sysmaxlong&lt;/STRONG&gt; from sashelp.class;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above code will generate following local macro variables name1,name2,name3,name4 etc., till name19.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jagadish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jul 2013 04:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129802#M26495</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2013-07-10T04:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically add macro variables to %LOCAL statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129803#M26496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;Astounding wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Not too difficult ...&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;You're allowed to specify a macro variable name that will resolve, such as:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;%local sales&amp;amp;i;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;So you could run with this code:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;%local i;&lt;/P&gt;
&lt;P&gt;%do i=1 %to &amp;amp;nsales;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %local sales&amp;amp;i;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;The tricky part is that you can actually insert this code between your SELECT statements.&amp;nbsp; Each SELECT statement runs immediately, and the %DO loop also runs immediately.&amp;nbsp; So the statements would all run in the proper order.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now why didn't I think of that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jul 2013 12:18:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129803#M26496</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2013-07-10T12:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically add macro variables to %LOCAL statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129804#M26497</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am sorry but the statement the that the "%do loop would run at the same time as the proc select" is incorrect. &lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#p06bq1j5uf0sz4n1vd3wx36tf0ud.htm" title="http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#p06bq1j5uf0sz4n1vd3wx36tf0ud.htm"&gt;SAS(R) 9.3 Macro Language: Reference&lt;/A&gt; (how the macro Processor compiles a macro defnition)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Be happy, the default creation scope is local. &lt;BR /&gt;The problem will arise when you need them to be global or have a conflicting global name.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#n0i4icf2nv7wu7n1lm4wf1epykfh.htm" title="http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#n0i4icf2nv7wu7n1lm4wf1epykfh.htm"&gt;SAS(R) 9.3 Macro Language: Reference&lt;/A&gt;&amp;nbsp; (forcing a macro variable to be local - Examples of macro variablescopes)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These are just te doc-refs to underpin what Ksharp stated. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 06:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129804#M26497</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2013-07-11T06:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically add macro variables to %LOCAL statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129805#M26498</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a way to make these variables global. Why following code doesn't work&lt;/P&gt;&lt;P&gt;% macro m1;&lt;/P&gt;&lt;P style="font-size: 24px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-size: 24px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;%global sales&amp;amp;i;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;SPAN style="font-size: 24px;"&gt;%local i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 24px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;%do i=1 %to 5;&lt;/P&gt;&lt;P style="font-size: 24px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp;&amp;nbsp; %let sales&amp;amp;i=&amp;amp;I;&lt;/P&gt;&lt;P style="font-size: 24px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;%end;&lt;/P&gt;&lt;P style="font-size: 24px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;% mend;&lt;/P&gt;&lt;P style="font-size: 24px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;% m1&lt;/P&gt;&lt;P style="font-size: 24px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-size: 24px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;% put &amp;amp;sales1;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 16:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129805#M26498</guid>
      <dc:creator>forumsguy</dc:creator>
      <dc:date>2013-07-11T16:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically add macro variables to %LOCAL statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129806#M26499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jaap Karman,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There must be another way to interpret the documentation.&amp;nbsp; Here's a test program that you can run (once leaving the comment statement in place, and once uncommenting it) to confirm that the program works as posted:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; data temp; do i=21 to 25; output; end; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select count(distinct i) into : n_vars from temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %local i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %do i=1 %to &amp;amp;n_vars;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %local sales&amp;amp;i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %let n_vars = &amp;amp;n_vars;&lt;/P&gt;&lt;P&gt;&amp;nbsp; *select distinct i into : sales1 -: sales&amp;amp;n_vars from temp;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%put _user_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend test;&lt;/P&gt;&lt;P&gt;options mprint;&lt;/P&gt;&lt;P&gt;%test&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The %DO loop can be compiled ahead of time (at least partially since &amp;amp;n_vars is not yet known).&amp;nbsp; But it doesn't execute ahead of time.&amp;nbsp; That's a feature of PROC SQL ... the SELECT statements run right away without looking for a QUIT (or a RUN) statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 19:50:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129806#M26499</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-07-11T19:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically add macro variables to %LOCAL statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129807#M26500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;forumsguy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your code isn't working because &amp;amp;i doesn't exist at the time that the %GLOBAL statement attempts to execute.&amp;nbsp; Move the %GLOBAL statement inside the loop, before the %LET statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 19:53:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129807#M26500</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-07-11T19:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically add macro variables to %LOCAL statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129808#M26501</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@Astounding,&lt;BR /&gt;I just has given you to the documentational links a I have done solving this kind of issue for many years...&amp;nbsp; Nearly about some 30 of them,&lt;BR /&gt;I was supporting SAS in a former big organization connecting Windows Unix and Mainframe together freeing the users/analists of this kind of issues.&lt;/P&gt;&lt;P&gt;All kind of macro issues are burned into my fingers. I referred KSharp as recognizing the value of his statement.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;As said and documented the local definition is not needed/ This is tested and used many times. You can test it by removing it, and it still will run.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Aside the scope also macro quiting can be very challenging. Wanting to combine it with SAS/connect or SQL pass-thru is giving a lot other nice things. As a nice&amp;nbsp; sample I put on my personal site: &lt;A href="http://metier.jakarman.nl/smpl111.html" title="http://metier.jakarman.nl/smpl111.html"&gt;Sample Securing Business keys and passwords &lt;/A&gt;(%keypsw) &lt;BR /&gt;It solves the issue of eliminating key/psw in code. By the way this macro knowledge is part of SAS -advanced. After all years I started to collect some of those certifications. You can find me on linkedin as you probably wish.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 20:13:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129808#M26501</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2013-07-11T20:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically add macro variables to %LOCAL statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129809#M26502</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jaap Karman,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're absolutely right that INTO : creates %LOCAL variables automatically.&amp;nbsp; However, INTO : doesn't always have to create a new macro variable.&amp;nbsp; What if the %GLOBAL environment already contains a macro variable &amp;amp;SALES1 and you want the INTO : version of &amp;amp;SALES1 to appear in the %LOCAL table?&amp;nbsp; Then the %LOCAL statements are necessary.&amp;nbsp; It's never a bad idea to add %LOCAL statements to guard against this possibility.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 20:25:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129809#M26502</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-07-11T20:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically add macro variables to %LOCAL statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129810#M26503</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Astounding,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; SAS is often using an approach like &lt;A href="http://en.wikipedia.org/wiki/Lazy_initialization" title="http://en.wikipedia.org/wiki/Lazy_initialization"&gt;Lazy initialization - Wikipedia, the free encyclopedia&lt;/A&gt; By that you are right being more formal.&lt;/P&gt;&lt;P&gt;in the TTA glossary of istqb.org you can find the same approach of quality testing of technical software (code review). &lt;BR /&gt;As the macro-code defining the scope must run before they are used the number and must be known in advance.&lt;/P&gt;&lt;P&gt;The nice thing with proc SQL is it will fill them with naming conventions numbers added etc dependent of it contens. There is the contradiction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And SAS is not Always correct in their handling. This one &lt;A href="http://support.sas.com/kb/31/887.html" title="http://support.sas.com/kb/31/887.html"&gt;31887 - Problems with macro variables Created in an AUTOEXEC.SAS file when executing SAS on a workspace server&lt;/A&gt; is an sample how surprising wrong it can be (experienced by hitting).&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 20:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-dynamically-add-macro-variables-to-LOCAL-statement/m-p/129810#M26503</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2013-07-11T20:45:33Z</dc:date>
    </item>
  </channel>
</rss>

