<?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: Retain Keyword in Macro. in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Retain-Keyword-in-Macro/m-p/548465#M8522</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240933"&gt;@jaiganesh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Retain Keyword (...) what would be it's alternative for Macro to do incremental addition&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240933"&gt;@jaiganesh&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The primary purpose of the &lt;A href="https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=p0t2ac0tfzcgbjn112mu96hkgg9o.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;RETAIN statement&lt;/A&gt; in the DATA step is to prevent certain variables from being reset to missing at the beginning of a new iteration of the DATA step (implied loop).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a SAS macro:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;there is neither an implied loop nor a mechanism that automatically (iteratively) clears macro variables.&lt;/LI&gt;
&lt;LI&gt;Incremental additions (if any) would typically occur in a %DO loop and don't require anything similar to a RETAIN statement (which wouldn't be needed even in an analogous DATA step DO loop anyway).&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
%let s=0;
%do i=20 %to 40 %by 10;
  %let s=%eval(&amp;amp;s+&amp;amp;i);
%end;
%put &amp;amp;=s; /* result: 90 */
%mend test;

%test&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Apr 2019 12:13:40 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2019-04-04T12:13:40Z</dc:date>
    <item>
      <title>Retain Keyword in Macro.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Retain-Keyword-in-Macro/m-p/548350#M8507</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can we use Retain Keyword in Macro ? I believe not, Just wanted to confirm, if not what would be it's alternative for Macro to do incremental addition&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jaiganesh&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 21:20:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Retain-Keyword-in-Macro/m-p/548350#M8507</guid>
      <dc:creator>jaiganesh</dc:creator>
      <dc:date>2019-04-03T21:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Keyword in Macro.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Retain-Keyword-in-Macro/m-p/548353#M8508</link>
      <description>&lt;P&gt;May I ask &lt;STRONG&gt;where, when and why&lt;/STRONG&gt; would the subject of Retain appear in a text processing facility that doesn't process PDV or in other words execution that's done by the datastep compiler.&amp;nbsp; If you answer the &lt;STRONG&gt;3 W's , &lt;/STRONG&gt;that will help.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 21:25:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Retain-Keyword-in-Macro/m-p/548353#M8508</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-03T21:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Keyword in Macro.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Retain-Keyword-in-Macro/m-p/548355#M8509</link>
      <description>&lt;P&gt;You do not, I repeat&amp;nbsp;&lt;FONT size="5"&gt;&lt;STRONG&gt;NOT&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;, process data with the macro preprocessor, which is there only for making code dynamic, if such is needed.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;Your question therefore shows a complete cluelessness about the subject. You need to deepen your understanding of the Base SAS language quite a lot before you even&amp;nbsp;&lt;EM&gt;think&lt;/EM&gt; about macros.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 21:50:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Retain-Keyword-in-Macro/m-p/548355#M8509</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-03T21:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Keyword in Macro.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Retain-Keyword-in-Macro/m-p/548393#M8511</link>
      <description>&lt;P&gt;You can use a macro program to generate any SAS code (or any other text for that matter) so I don't see any reason why would have any trouble generating a RETAIN statement. Or for that matter use the word RETAIN as a the name of a variable or macro variable.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 03:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Retain-Keyword-in-Macro/m-p/548393#M8511</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-04T03:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Keyword in Macro.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Retain-Keyword-in-Macro/m-p/548465#M8522</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240933"&gt;@jaiganesh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Retain Keyword (...) what would be it's alternative for Macro to do incremental addition&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240933"&gt;@jaiganesh&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The primary purpose of the &lt;A href="https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=p0t2ac0tfzcgbjn112mu96hkgg9o.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;RETAIN statement&lt;/A&gt; in the DATA step is to prevent certain variables from being reset to missing at the beginning of a new iteration of the DATA step (implied loop).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a SAS macro:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;there is neither an implied loop nor a mechanism that automatically (iteratively) clears macro variables.&lt;/LI&gt;
&lt;LI&gt;Incremental additions (if any) would typically occur in a %DO loop and don't require anything similar to a RETAIN statement (which wouldn't be needed even in an analogous DATA step DO loop anyway).&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
%let s=0;
%do i=20 %to 40 %by 10;
  %let s=%eval(&amp;amp;s+&amp;amp;i);
%end;
%put &amp;amp;=s; /* result: 90 */
%mend test;

%test&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 12:13:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Retain-Keyword-in-Macro/m-p/548465#M8522</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-04-04T12:13:40Z</dc:date>
    </item>
  </channel>
</rss>

