<?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: simplify do loops in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/simplify-do-loops/m-p/879206#M347351</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/173636"&gt;@Satori&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;12/j*values(i)&lt;/LI-CODE&gt;
&lt;P&gt;is not a complete statement. You will need something like&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;x=12/j*values(i)&lt;/LI-CODE&gt;
&lt;P&gt;or in your case&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;values(i)=12/j*values(i)&lt;/LI-CODE&gt;
&lt;P&gt;(I just looked at the one syntax part)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Markus&lt;/P&gt;</description>
    <pubDate>Mon, 05 Jun 2023 05:13:44 GMT</pubDate>
    <dc:creator>MarkusWeick</dc:creator>
    <dc:date>2023-06-05T05:13:44Z</dc:date>
    <item>
      <title>simplify do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/simplify-do-loops/m-p/879204#M347349</link>
      <description>&lt;P&gt;my code (that works):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data home.test2; set bv18u; array values (*) COGS--EBITDA; do i = 1 to dim(values);
	if nmonths=1 then values(i) = 12/1*values(i); else if Number_of_months=2 then values(i) = 12/2*values(i);
	else if nmonths=3 then values(i) = 12/3*values(i); else if nmonths=4 then values(i) = 12/4*values(i);
	else if nmonths=5 then values(i) = 12/5*values(i); else if nmonths=6 then values(i) = 12/6*values(i);
	else if nmonths=7 then values(i) = 12/7*values(i); else if nmonths=8 then values(i) = 12/8*values(i);
	else if nmonths=9 then values(i) = 12/9*values(i); else if nmonths=10 then values(i) = 12/10*values(i);
	else if nmonths=11 then values(i) = 12/11*values(i); else if nmonths=12 then values(i) = 12/12*values(i);
	else if nmonths=13 then values(i) = 12/13*values(i); else if nmonths=14 then values(i) = 12/14*values(i);
	else if nmonths=15 then values(i) = 12/15*values(i); else if nmonths=16 then values(i) = 12/16*values(i);
	else if nmonths=17 then values(i) = 12/17*values(i); else if nmonths=18 then values(i) = 12/18*values(i);
	else if nmonths=19 then values(i) = 12/19*values(i); else if nmonths=20 then values(i) = 12/20*values(i);
	else if nmonths=21 then values(i) = 12/21*values(i); else if nmonths=22 then values(i) = 12/22*values(i);
	else if nmonths=23 then values(i) = 12/23*values(i); else if nmonths=24 then values(i) = 12/24*values(i);
	end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to simplify this code I tried doing (that doesn't work):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data home.test1; set bv18u; array values (*) COGS--EBITDA; do i = 1 to dim(values);
	do j=1 to 24; if nmonths=j then 12/j*values(i); end; end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and I got an error. log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   

733        data bvd.test1; set bv18u; array values (*) COGS--EBITDA; do i = 1 to dim(values);
734        	do j=1 to 24; if nmonths=j then 12/j*values(i); end; end;
                                                     __
                                                     180
ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2023 03:53:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/simplify-do-loops/m-p/879204#M347349</guid>
      <dc:creator>Satori</dc:creator>
      <dc:date>2023-06-05T03:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: simplify do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/simplify-do-loops/m-p/879206#M347351</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/173636"&gt;@Satori&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;12/j*values(i)&lt;/LI-CODE&gt;
&lt;P&gt;is not a complete statement. You will need something like&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;x=12/j*values(i)&lt;/LI-CODE&gt;
&lt;P&gt;or in your case&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;values(i)=12/j*values(i)&lt;/LI-CODE&gt;
&lt;P&gt;(I just looked at the one syntax part)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Markus&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2023 05:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/simplify-do-loops/m-p/879206#M347351</guid>
      <dc:creator>MarkusWeick</dc:creator>
      <dc:date>2023-06-05T05:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: simplify do loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/simplify-do-loops/m-p/879207#M347352</link>
      <description>&lt;P&gt;You need a complete assignment statement, and can omit the DO:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data home.test1;
set bv18u;
array values (*) COGS--EBITDA;
do i = 1 to dim(values);
  if 1 le nmonths le 24 then values{i} = 12 / nmonths * values{i};
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Jun 2023 05:49:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/simplify-do-loops/m-p/879207#M347352</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-06-05T05:49:28Z</dc:date>
    </item>
  </channel>
</rss>

