<?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: Arrays and Do Loops in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/541153#M149374</link>
    <description>&lt;P&gt;Thanks for your response. Is there a way to add the new data vertically like the following?&lt;/P&gt;&lt;P&gt;Date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X&lt;/P&gt;&lt;P&gt;jan2019&amp;nbsp;&amp;nbsp;&amp;nbsp; 100&lt;/P&gt;&lt;P&gt;Feb2019&amp;nbsp;&amp;nbsp; 110&lt;/P&gt;&lt;P&gt;March2019 120 ....&lt;/P&gt;</description>
    <pubDate>Thu, 07 Mar 2019 17:04:38 GMT</pubDate>
    <dc:creator>parmis</dc:creator>
    <dc:date>2019-03-07T17:04:38Z</dc:date>
    <item>
      <title>Arrays and Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/540924#M149278</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set that contains a date filed&amp;nbsp;(Jan 2019&amp;nbsp;) and&amp;nbsp; X(which is a number). I'd like to increase the X filed by 1.2% each month for the next 12 months.&lt;/P&gt;&lt;P&gt;for example if the value for Jan 2019 is 120, for February it will be 121.4 (120*(1+1.2)), but then I'd like to increase the new number by 1.2% for the next month and repeat the process for 12 months.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate your help.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 20:58:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/540924#M149278</guid>
      <dc:creator>parmis</dc:creator>
      <dc:date>2019-03-06T20:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays and Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/540926#M149279</link>
      <description>&lt;P&gt;Assumes your DATE variable contains actual numeric SAS date values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    array xs x1-x12;
    array months month1-month12;
    x1=x;
    month1=date;
    do i=2 to dim(xs);
        xs(i)=xs(i-1)*1.012;
        months(i) = intnx('month',months(i-1),1,'b');
    end;
    drop i;
    format month: monyy7.;
run;
        &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Mar 2019 12:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/540926#M149279</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-07T12:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays and Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/540929#M149282</link>
      <description>And if your date variable is not a sas-date, fix that issue before you do anything else with the data.</description>
      <pubDate>Wed, 06 Mar 2019 21:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/540929#M149282</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-03-06T21:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays and Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/540937#M149288</link>
      <description>&lt;P&gt;I didn't quite get a clear sense of what you wanted your output to look like but maybe this might be the code you are looking for:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* CREATING THE DUMMY DATA */&lt;BR /&gt;data have;&lt;BR /&gt;input date :monyy7. x @@;&lt;BR /&gt;format date MONYY7.;&lt;BR /&gt;CARDS;&lt;BR /&gt;JAN1990 345 MAR2009 980 NOV1973 290 FEB2011 330&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;array m(*) AfterMonth1-AfterMonth12;&lt;BR /&gt;AfterMonth1=x * 1.012;&lt;BR /&gt;do i = 2 to 12;drop i;&lt;BR /&gt;m(i)=round((m(i-1) * 1.012),.01);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Screen Shot 2019-03-07 at 3.09.09 AM.png" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27725iF1AE0FFF270D4301/image-size/small?v=v2&amp;amp;px=200" role="button" title="Screen Shot 2019-03-07 at 3.09.09 AM.png" alt="Screen Shot 2019-03-07 at 3.09.09 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 21:40:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/540937#M149288</guid>
      <dc:creator>jfaruqui</dc:creator>
      <dc:date>2019-03-06T21:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays and Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/541153#M149374</link>
      <description>&lt;P&gt;Thanks for your response. Is there a way to add the new data vertically like the following?&lt;/P&gt;&lt;P&gt;Date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X&lt;/P&gt;&lt;P&gt;jan2019&amp;nbsp;&amp;nbsp;&amp;nbsp; 100&lt;/P&gt;&lt;P&gt;Feb2019&amp;nbsp;&amp;nbsp; 110&lt;/P&gt;&lt;P&gt;March2019 120 ....&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 17:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/541153#M149374</guid>
      <dc:creator>parmis</dc:creator>
      <dc:date>2019-03-07T17:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays and Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/541165#M149375</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183598"&gt;@parmis&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your response. Is there a way to add the new data vertically like the following?&lt;/P&gt;
&lt;P&gt;Date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X&lt;/P&gt;
&lt;P&gt;jan2019&amp;nbsp;&amp;nbsp;&amp;nbsp; 100&lt;/P&gt;
&lt;P&gt;Feb2019&amp;nbsp;&amp;nbsp; 110&lt;/P&gt;
&lt;P&gt;March2019 120 ....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Well, not with ARRAYS, which aren't needed here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    output;
    do i=2 to 12;
        x=x*1.012;
        month = intnx('month',month,1,'b');
        output;
    end;
    format month monyy7.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Mar 2019 17:43:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/541165#M149375</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-07T17:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays and Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/541169#M149376</link>
      <description>&lt;P&gt;Thank you very much, this is exactly what I wanted but the dates are not changing. I have the first row of data(Jan2019) for all 12 months.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 18:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/541169#M149376</guid>
      <dc:creator>parmis</dc:creator>
      <dc:date>2019-03-07T18:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays and Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/541171#M149377</link>
      <description>&lt;P&gt;My code calls the variable MONTH and not DATE, which apparently is what you call the variable. You'd have to make that change.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 18:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-and-Do-Loops/m-p/541171#M149377</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-07T18:14:47Z</dc:date>
    </item>
  </channel>
</rss>

