<?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: can the i value in a do loop statement be used as a macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/can-the-i-value-in-a-do-loop-statement-be-used-as-a-macro/m-p/477677#M123077</link>
    <description>&lt;P&gt;You cannot mix and match. Data step variables are data step variables, they are not macro variables. Macro variables are macro variables, they are not data step variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Much simpler approach, since variable I is a data step variable, and you are in a data step, then use variable I as a data step variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    do i=1 to 69;
         set sdtmall1;
         call symputx(cats('in',i),memname);
         call symputx(cats('seq',i),name);
         /* output; */  &amp;lt;--- The output statement simply isn't needed here
     end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Also note that indenting makes your code easier to read.&lt;/P&gt;</description>
    <pubDate>Thu, 12 Jul 2018 20:13:18 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-07-12T20:13:18Z</dc:date>
    <item>
      <title>can the i value in a do loop statement be used as a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-the-i-value-in-a-do-loop-statement-be-used-as-a-macro/m-p/477675#M123075</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;When i ran second data step i am getting errors. Is it possible to use&amp;nbsp;&amp;nbsp;'i' values as macro variable as in second data step. Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;data sdtmall1(keep=memname name);
set sdtmall;
if index(name,'SEQ')&amp;gt;0 or index(name,'IDVARVAL')&amp;gt;0;
run;

data one;
do i=1 to 69;
set sdtmall1;
call symputx('in&amp;amp;i.',memname);
call symputx('seq&amp;amp;i.',name);
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Jul 2018 20:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-the-i-value-in-a-do-loop-statement-be-used-as-a-macro/m-p/477675#M123075</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2018-07-12T20:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: can the i value in a do loop statement be used as a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-the-i-value-in-a-do-loop-statement-be-used-as-a-macro/m-p/477677#M123077</link>
      <description>&lt;P&gt;You cannot mix and match. Data step variables are data step variables, they are not macro variables. Macro variables are macro variables, they are not data step variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Much simpler approach, since variable I is a data step variable, and you are in a data step, then use variable I as a data step variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    do i=1 to 69;
         set sdtmall1;
         call symputx(cats('in',i),memname);
         call symputx(cats('seq',i),name);
         /* output; */  &amp;lt;--- The output statement simply isn't needed here
     end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Also note that indenting makes your code easier to read.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 20:13:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-the-i-value-in-a-do-loop-statement-be-used-as-a-macro/m-p/477677#M123077</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-12T20:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: can the i value in a do loop statement be used as a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-the-i-value-in-a-do-loop-statement-be-used-as-a-macro/m-p/477684#M123079</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the reply. I have one more issuethat i am not able to understand. Please help. Thank you.&lt;/P&gt;
&lt;P&gt;After you code&amp;nbsp; i am able to create macro variables, but i need to use the below macro code. why the data step is not running. Thank you&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;data _null_;
    do i=1 to 3;
         set sdtmall1;
         call symputx(cats('in',i),memname);
         call symputx(cats('seq',i),name);

%macro duplicates(in=,seq=);
proc sort data=sdtm.&amp;amp;in. out=_null_ dupout=dups__&amp;amp;in. nodupkey;
       by usubjid &amp;amp;seq.;
  run;
  proc print data=dups__&amp;amp;in. width=min ;
  	   title " Dups in sdtm.&amp;amp;in.";
  	   var usubjid &amp;amp;seq.;
  run;	 
%mend;

%duplicates(in=&amp;amp;ini.,seq=&amp;amp;seqi.);
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 20:51:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-the-i-value-in-a-do-loop-statement-be-used-as-a-macro/m-p/477684#M123079</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2018-07-12T20:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: can the i value in a do loop statement be used as a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-the-i-value-in-a-do-loop-statement-be-used-as-a-macro/m-p/477690#M123083</link>
      <description>&lt;P&gt;Whenever you create a macro (or a macro variable) and use it, the result must be VALID SAS CODE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, you can't have a PROC SORT and PROC PRINT inside a data step. That is not valid SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your code, you could call the macro %DUPLICATES after the RUN; that ends the data step. That would be LEGAL SAS CODE. Whether it is actually what you want or not, I don't know.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 11:05:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-the-i-value-in-a-do-loop-statement-be-used-as-a-macro/m-p/477690#M123083</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-13T11:05:00Z</dc:date>
    </item>
  </channel>
</rss>

