<?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 Difference between %do iterative and do iterative in a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-do-iterative-and-do-iterative-in-a-macro/m-p/478367#M123372</link>
    <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my below pgm I want to know the difference between duplicate 1 macro and duplicate 2 macro. I am able to produce macro variables with values in&amp;nbsp; first macro but not second. Please help me understand. Thank you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sdtmall1;
input memname $ name $;
datalines;
AE AESEQ
BS BSSEQ
CM CMSEQ
;
%macro duplicates1;
data one;
    do i=1 to 3;
         set sdtmall1;

         call symputx(cats('in',i),memname);
         call symputx(cats('seq',i),name);
		
     end;
run;%mend;
%duplicates1;
%put &amp;amp;in1;
%put &amp;amp;in2;
%put &amp;amp;in3;

%macro duplicates2;
data one;
    %do i=1 %to 3;
         set sdtmall1;

         call symputx(cats('inn',&amp;amp;i.),memname);
         call symputx(cats('seqq',&amp;amp;i.),name);
		
     %end;
run;%mend;
%duplicates2;
%put &amp;amp;inn1;
%put &amp;amp;inn2;
%put &amp;amp;inn3;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 16 Jul 2018 14:26:04 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2018-07-16T14:26:04Z</dc:date>
    <item>
      <title>Difference between %do iterative and do iterative in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-do-iterative-and-do-iterative-in-a-macro/m-p/478367#M123372</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my below pgm I want to know the difference between duplicate 1 macro and duplicate 2 macro. I am able to produce macro variables with values in&amp;nbsp; first macro but not second. Please help me understand. Thank you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sdtmall1;
input memname $ name $;
datalines;
AE AESEQ
BS BSSEQ
CM CMSEQ
;
%macro duplicates1;
data one;
    do i=1 to 3;
         set sdtmall1;

         call symputx(cats('in',i),memname);
         call symputx(cats('seq',i),name);
		
     end;
run;%mend;
%duplicates1;
%put &amp;amp;in1;
%put &amp;amp;in2;
%put &amp;amp;in3;

%macro duplicates2;
data one;
    %do i=1 %to 3;
         set sdtmall1;

         call symputx(cats('inn',&amp;amp;i.),memname);
         call symputx(cats('seqq',&amp;amp;i.),name);
		
     %end;
run;%mend;
%duplicates2;
%put &amp;amp;inn1;
%put &amp;amp;inn2;
%put &amp;amp;inn3;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Jul 2018 14:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-do-iterative-and-do-iterative-in-a-macro/m-p/478367#M123372</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2018-07-16T14:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between %do iterative and do iterative in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-do-iterative-and-do-iterative-in-a-macro/m-p/478380#M123374</link>
      <description>&lt;P&gt;The first macro works, but it is somewhat lucky that it does so.&amp;nbsp; There are no %local macro variables at the time the program runs CALL SYMPUTX.&amp;nbsp; Therefore CALL SYMPUTX creates macro variables in the global macro environment, so that they still exist when the macro is over.&amp;nbsp; It would be safer to add a third parameter to CALL SYMPUTX to make sure that (in more complex applications) the macro variables created will exist in the global environment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second macro&amp;nbsp;illustrates that the author is not well schooled in either SAS language or macro language.&amp;nbsp; Because &amp;amp;I exists in the local environment, CALL SYMPUTX creates macro variables in the local environment.&amp;nbsp; By the time the final %PUT statements execute, the local environment (and the macro variables created) have vanished.&amp;nbsp; You can illustrate this (as well as additional issues involved that are getting the wrong values assigned) by moving the final %PUT statements inside the macro, between the RUN and %MEND statements.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 14:57:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-do-iterative-and-do-iterative-in-a-macro/m-p/478380#M123374</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-07-16T14:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between %do iterative and do iterative in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-do-iterative-and-do-iterative-in-a-macro/m-p/478382#M123376</link>
      <description>&lt;P&gt;The macro preprocessor deals with&amp;nbsp;&lt;EM&gt;program code&lt;/EM&gt;, the data step deals with&amp;nbsp;&lt;EM&gt;data&lt;/EM&gt;. While the datastep do loop repeats the&amp;nbsp;&lt;EM&gt;same&lt;/EM&gt;&amp;nbsp;data step statements, the %do loop repeatedly creates&amp;nbsp;&lt;EM&gt;separate&lt;/EM&gt; data step statements. One set in a do loop works different than three separate set statements created by the %do.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 14:58:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-do-iterative-and-do-iterative-in-a-macro/m-p/478382#M123376</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-16T14:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between %do iterative and do iterative in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-do-iterative-and-do-iterative-in-a-macro/m-p/478405#M123382</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
set sdtmall1;
retain count 0;
count = count + 1;
call symputx(cats('in',count),memname);
call symputx(cats('seq',count),name);
run;

%put &amp;amp;in1 &amp;amp;in2 &amp;amp;in3;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Jul 2018 15:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-do-iterative-and-do-iterative-in-a-macro/m-p/478405#M123382</guid>
      <dc:creator>MadhuKorni</dc:creator>
      <dc:date>2018-07-16T15:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between %do iterative and do iterative in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-do-iterative-and-do-iterative-in-a-macro/m-p/478421#M123387</link>
      <description>&lt;P&gt;Turn on the MPRINT option to see the different SAS code that the two macros generate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also make sure to define the macro variables INN1,INN2, etc before calling the second macro so that they will be available after the macro ends.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-do-iterative-and-do-iterative-in-a-macro/m-p/478421#M123387</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-16T17:10:37Z</dc:date>
    </item>
  </channel>
</rss>

