<?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: Macro within a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-macro/m-p/722607#M224082</link>
    <description>&lt;P&gt;Look up CALL EXECUTE.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The documentation has an example.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222217"&gt;@di_niu0&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello, I have a problem with the below code. %gettime is a macro which gives the 100th day after the start date and outputs a table. I would like to get table1 which gives the 100th day after date1, table2 which gives 100th day after date2...Until date12. But the code only gives me table1. I am not sure what's wrong with the code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%do i=1 %to 12;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%getdate(&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;start = date&amp;amp;i,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out = table&amp;amp;i);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%end;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%date;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Mar 2021 16:04:37 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-03-01T16:04:37Z</dc:date>
    <item>
      <title>Macro within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-macro/m-p/722599#M224078</link>
      <description>&lt;P&gt;Hello, I have a problem with the below code. %gettime is a macro which gives the 100th day after the start date and outputs a table. I would like to get table1 which gives the 100th day after date1, table2 which gives 100th day after date2...Until date12. But the code only gives me table1. I am not sure what's wrong with the code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro date;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%do i=1 %to 12;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%getdate(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;start = date&amp;amp;i,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out = table&amp;amp;i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%date;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 15:36:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-macro/m-p/722599#M224078</guid>
      <dc:creator>di_niu0</dc:creator>
      <dc:date>2021-03-01T15:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-macro/m-p/722603#M224079</link>
      <description>&lt;P&gt;Not much information to work with:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 385px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55318iFF60C32B06E4EE92/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;P&gt;Modify the definition of the GETDATE macro and add this statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%local i;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 15:59:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-macro/m-p/722603#M224079</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-01T15:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-macro/m-p/722604#M224080</link>
      <description>Hello, thank you for your reply. Do you mean add %local i into the GETDATE macro?</description>
      <pubDate>Mon, 01 Mar 2021 15:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-macro/m-p/722604#M224080</guid>
      <dc:creator>di_niu0</dc:creator>
      <dc:date>2021-03-01T15:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-macro/m-p/722606#M224081</link>
      <description>&lt;P&gt;Yes.&amp;nbsp; Your posted code is setting I=1 then calling GETDATE.&amp;nbsp; The %DO loop then increments I by 1 and tests if it is greater than 12.&amp;nbsp; So GETDATE must be changing I to a value that is 11 or larger.&amp;nbsp; If you tell GETDATE to use a LOCAL macro variable instead of the existing macro variable then it will not modify the variable being used for the %DO loop.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 16:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-macro/m-p/722606#M224081</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-01T16:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-macro/m-p/722607#M224082</link>
      <description>&lt;P&gt;Look up CALL EXECUTE.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The documentation has an example.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222217"&gt;@di_niu0&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello, I have a problem with the below code. %gettime is a macro which gives the 100th day after the start date and outputs a table. I would like to get table1 which gives the 100th day after date1, table2 which gives 100th day after date2...Until date12. But the code only gives me table1. I am not sure what's wrong with the code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%do i=1 %to 12;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%getdate(&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;start = date&amp;amp;i,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out = table&amp;amp;i);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%end;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%date;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 16:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-macro/m-p/722607#M224082</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-01T16:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-macro/m-p/722609#M224085</link>
      <description>Thank you!</description>
      <pubDate>Mon, 01 Mar 2021 16:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-macro/m-p/722609#M224085</guid>
      <dc:creator>di_niu0</dc:creator>
      <dc:date>2021-03-01T16:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-macro/m-p/722610#M224086</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I'm happy to help. However can you give an overview of your macro getname.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 16:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-macro/m-p/722610#M224086</guid>
      <dc:creator>classe_i_k</dc:creator>
      <dc:date>2021-03-01T16:08:04Z</dc:date>
    </item>
  </channel>
</rss>

