<?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: One more variable in DO loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/One-more-variable-in-DO-loop/m-p/490800#M128526</link>
    <description>&lt;P&gt;I guess you'd rather want to have this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro m(start=,end=);
proc expand
  data=A1 (keep=ID date AAA)
  out=A3
  method=none
;
by permno;
id date;
%do i=&amp;amp;start %to &amp;amp;end;
convert AAA = AAA_&amp;amp;i / transformout=(reverse MOVPROD &amp;amp;i reverse trimright %eval(&amp;amp;i-1));
%end;
run;
%mend m;
%m(start=2,end=50);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 29 Aug 2018 12:06:16 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-08-29T12:06:16Z</dc:date>
    <item>
      <title>One more variable in DO loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/One-more-variable-in-DO-loop/m-p/490790#M128519</link>
      <description>&lt;P&gt;%macro m(start=,end=);&lt;BR /&gt;proc expand data=A1 (keep=ID date AAA) out=A3 method=none;&lt;BR /&gt;%do i=&amp;amp;start %to &amp;amp;end;&lt;BR /&gt;by permno;&lt;BR /&gt;id date;&lt;BR /&gt;convert&amp;nbsp;AAA = AAA_&amp;amp;i / transformout=(reverse MOVPROD &amp;amp;i reverse trimright &lt;STRONG&gt;&amp;amp;j&lt;/STRONG&gt;);&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;BR /&gt;%mend m;&lt;BR /&gt;%m(start=2,end=50);&lt;/P&gt;
&lt;P&gt;--------------------------------------------------&lt;/P&gt;
&lt;P&gt;Here how to code j ? j=i-1&lt;/P&gt;
&lt;P&gt;It is incorrect if I just use "&amp;amp;i-1" in the transformout. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 11:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/One-more-variable-in-DO-loop/m-p/490790#M128519</guid>
      <dc:creator>ZZB</dc:creator>
      <dc:date>2018-08-29T11:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: One more variable in DO loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/One-more-variable-in-DO-loop/m-p/490796#M128524</link>
      <description>&lt;P&gt;For integer calculations in macro code you need the %eval() macro function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But do you really want to repeat the statements&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;by permno;
id date;
convert AAA = AAA_&amp;amp;i / transformout=(reverse MOVPROD &amp;amp;i reverse trimright &amp;amp;j);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;49 times in one proc expand?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 11:56:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/One-more-variable-in-DO-loop/m-p/490796#M128524</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-29T11:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: One more variable in DO loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/One-more-variable-in-DO-loop/m-p/490800#M128526</link>
      <description>&lt;P&gt;I guess you'd rather want to have this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro m(start=,end=);
proc expand
  data=A1 (keep=ID date AAA)
  out=A3
  method=none
;
by permno;
id date;
%do i=&amp;amp;start %to &amp;amp;end;
convert AAA = AAA_&amp;amp;i / transformout=(reverse MOVPROD &amp;amp;i reverse trimright %eval(&amp;amp;i-1));
%end;
run;
%mend m;
%m(start=2,end=50);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Aug 2018 12:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/One-more-variable-in-DO-loop/m-p/490800#M128526</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-29T12:06:16Z</dc:date>
    </item>
  </channel>
</rss>

