<?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 Retain and Do Loops in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Retain-and-Do-Loops/m-p/468707#M119764</link>
    <description>&lt;P&gt;&amp;nbsp;I was able to get some help and get this far:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;do year = &amp;amp;FirstYear to &amp;amp;CurrentYr;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;retain m_03 0;&lt;BR /&gt;retain m_06 0;&lt;BR /&gt;retain m_09 0;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, let's say I want my table to go to m_225, how would I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought I could use a do loop but it ended up giving me a weird table with the variable I used for my counter as a table column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Jun 2018 14:23:28 GMT</pubDate>
    <dc:creator>rrpking</dc:creator>
    <dc:date>2018-06-08T14:23:28Z</dc:date>
    <item>
      <title>Retain and Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-and-Do-Loops/m-p/468707#M119764</link>
      <description>&lt;P&gt;&amp;nbsp;I was able to get some help and get this far:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;do year = &amp;amp;FirstYear to &amp;amp;CurrentYr;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;retain m_03 0;&lt;BR /&gt;retain m_06 0;&lt;BR /&gt;retain m_09 0;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, let's say I want my table to go to m_225, how would I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought I could use a do loop but it ended up giving me a weird table with the variable I used for my counter as a table column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 14:23:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-and-Do-Loops/m-p/468707#M119764</guid>
      <dc:creator>rrpking</dc:creator>
      <dc:date>2018-06-08T14:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Retain and Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-and-Do-Loops/m-p/468710#M119765</link>
      <description>&lt;P&gt;??&lt;/P&gt;
&lt;P&gt;Sorry your post makes no sense.&amp;nbsp; Do you want new variables which have m_xyz up to 225?&amp;nbsp; If so then an array, however there would be better modelling techniques than 225 variables.&lt;/P&gt;
&lt;P&gt;The retain seems to be a bit pointless, just creating 3 variables with the same data.&amp;nbsp; And the do just creates a bunch of rows.&amp;nbsp; Not sure what you expect us to do with this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post test data in the form of a datastep&lt;/P&gt;
&lt;P&gt;Show what the output should look like&lt;/P&gt;
&lt;P&gt;Explain what the logic between the two is.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 14:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-and-Do-Loops/m-p/468710#M119765</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-08T14:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Retain and Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-and-Do-Loops/m-p/468713#M119766</link>
      <description>&lt;P&gt;You've got macro variables (&amp;amp;FirstYear and &amp;amp;CurrentYr) that don't seem to relate to anything else in the program. You've got a do loop that doesn't seem to relate to the retain statements. In short, we don't know what you are trying to do, and the code you have provided doesn't seem to make any sense. You tried something with this code (or was it some other code?) and the result was "weird", but we have no idea what that means either.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, please explain what you would like to do in words, and not in code. We need a clear and complete explanation, written so that your high school English teacher would give you a grade of A+. And then, we can probably provide code that will get the job done.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 14:34:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-and-Do-Loops/m-p/468713#M119766</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-06-08T14:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Retain and Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-and-Do-Loops/m-p/468714#M119767</link>
      <description>&lt;PRE&gt;array m_{255}  (255*0);&lt;/PRE&gt;
&lt;P&gt;If the variables do not exist an array statement such as this will make 255 variables, m_1 to m_255. The (255*0) is not multiplication but is the instruction to set all 255 varaibles to the value of 0 when the array is populated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Still no example of how this data is to be used. Creating that many zero valued variables often indicates that another approach may well be indicated.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 14:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-and-Do-Loops/m-p/468714#M119767</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-08T14:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Retain and Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-and-Do-Loops/m-p/468727#M119774</link>
      <description>&lt;P&gt;You can see a follow-up post to your original, with a good solution for this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Create-table-with-incremental-rows-and-years-for-columns/m-p/468725#M119772" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Create-table-with-incremental-rows-and-years-for-columns/m-p/468725#M119772&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 15:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-and-Do-Loops/m-p/468727#M119774</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-06-08T15:13:31Z</dc:date>
    </item>
  </channel>
</rss>

