<?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 Macro being generated from another macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Call-Macro-being-generated-from-another-macro/m-p/463808#M285011</link>
    <description>&lt;P&gt;When SQL creates macro variables, it creates them in the local symbol table.&amp;nbsp; But you need them to be global, so they will exist after %TEST finishes executing.&amp;nbsp; To do that, add this statement after %DO but before PROC SQL:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%global group&amp;amp;i;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, the later&amp;nbsp;WHERE statement is abbreviated.&amp;nbsp; In practice&amp;nbsp; you would be using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where (id in (&amp;amp;group1) or id in (&amp;amp;group2));&lt;/P&gt;</description>
    <pubDate>Mon, 21 May 2018 16:03:07 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-05-21T16:03:07Z</dc:date>
    <item>
      <title>Call Macro being generated from another macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Macro-being-generated-from-another-macro/m-p/463804#M285010</link>
      <description>&lt;P&gt;Dear SAS community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had a Macro to cut every 4000 records into a new macro which later I can use them as filters in my proc sql query, my macro is as following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%Macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test(test);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;test;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;select distinct &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"'"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;||ID||&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"'"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; into :group&amp;amp;i separated by &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;','&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;from BPLCheck.padrug (firstobs=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4000&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;*(&amp;amp;i-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;)+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) obs=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4000&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;*&amp;amp;i) )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;test&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, while I call the &amp;amp;group1 and &amp;amp;group 2 within my proc sql query in the where statement,&lt;/P&gt;&lt;P&gt;where (id in (&amp;amp;group1) or (&amp;amp;group2))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS can not recognize those two macros. What did I do wrong? How can I make this work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 15:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Macro-being-generated-from-another-macro/m-p/463804#M285010</guid>
      <dc:creator>Catherine212</dc:creator>
      <dc:date>2018-05-21T15:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Call Macro being generated from another macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Macro-being-generated-from-another-macro/m-p/463808#M285011</link>
      <description>&lt;P&gt;When SQL creates macro variables, it creates them in the local symbol table.&amp;nbsp; But you need them to be global, so they will exist after %TEST finishes executing.&amp;nbsp; To do that, add this statement after %DO but before PROC SQL:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%global group&amp;amp;i;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, the later&amp;nbsp;WHERE statement is abbreviated.&amp;nbsp; In practice&amp;nbsp; you would be using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where (id in (&amp;amp;group1) or id in (&amp;amp;group2));&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 16:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Macro-being-generated-from-another-macro/m-p/463808#M285011</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-21T16:03:07Z</dc:date>
    </item>
  </channel>
</rss>

