<?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 do loops and name appending in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/do-loops-and-name-appending/m-p/17389#M2517</link>
    <description>hi all,&lt;BR /&gt;
&lt;BR /&gt;
some help?&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;data newtable;&lt;BR /&gt;
	do i=1 to 5;&lt;BR /&gt;
	                 y_i.=i;&lt;BR /&gt;
	end;&lt;BR /&gt;
run;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
I want to keep the variables y_1, y_2 and so on (not i)&lt;BR /&gt;
&lt;BR /&gt;
thanks in advance,&lt;BR /&gt;
Sachin</description>
    <pubDate>Fri, 15 Oct 2010 02:46:51 GMT</pubDate>
    <dc:creator>SachinRuk</dc:creator>
    <dc:date>2010-10-15T02:46:51Z</dc:date>
    <item>
      <title>do loops and name appending</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loops-and-name-appending/m-p/17389#M2517</link>
      <description>hi all,&lt;BR /&gt;
&lt;BR /&gt;
some help?&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;data newtable;&lt;BR /&gt;
	do i=1 to 5;&lt;BR /&gt;
	                 y_i.=i;&lt;BR /&gt;
	end;&lt;BR /&gt;
run;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
I want to keep the variables y_1, y_2 and so on (not i)&lt;BR /&gt;
&lt;BR /&gt;
thanks in advance,&lt;BR /&gt;
Sachin</description>
      <pubDate>Fri, 15 Oct 2010 02:46:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loops-and-name-appending/m-p/17389#M2517</guid>
      <dc:creator>SachinRuk</dc:creator>
      <dc:date>2010-10-15T02:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: do loops and name appending</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loops-and-name-appending/m-p/17390#M2518</link>
      <description>You could initialize an array with the name of the variables that you want.  &lt;BR /&gt;
&lt;BR /&gt;
For example, you could have said &lt;B&gt;array y_(5);&lt;/B&gt;  Then you reference the array like so in the data step:  &lt;B&gt;y_(i) = value;&lt;/B&gt;.  When the array is stored in the dataset, it will actually be stored as y_1, y_2, etc.&lt;BR /&gt;
&lt;BR /&gt;
Note;  In the array statement, the number in parentheses tells sas how many elements you need in your array; for you example, it should match the number of iterations in the do loop.</description>
      <pubDate>Fri, 15 Oct 2010 04:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loops-and-name-appending/m-p/17390#M2518</guid>
      <dc:creator>Rambo</dc:creator>
      <dc:date>2010-10-15T04:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: do loops and name appending</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loops-and-name-appending/m-p/17391#M2519</link>
      <description>And, this is a very good introduction to ARRAY processing and ARRAY concepts in SAS:&lt;BR /&gt;
&lt;A href="http://support.sas.com/rnd/papers/sgf07/arrays1780.pdf" target="_blank"&gt;http://support.sas.com/rnd/papers/sgf07/arrays1780.pdf&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Fri, 15 Oct 2010 05:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loops-and-name-appending/m-p/17391#M2519</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-10-15T05:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: do loops and name appending</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loops-and-name-appending/m-p/17392#M2520</link>
      <description>Try this:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%macro sachin;&lt;BR /&gt;
data newtable;&lt;BR /&gt;
%do i=1 %to 5;&lt;BR /&gt;
%let j=&amp;amp;i.;&lt;BR /&gt;
y_&amp;amp;j.=&amp;amp;j.;&lt;BR /&gt;
%end;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend sachin;&lt;BR /&gt;
%sachin;</description>
      <pubDate>Mon, 18 Oct 2010 14:59:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loops-and-name-appending/m-p/17392#M2520</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-10-18T14:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: do loops and name appending</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loops-and-name-appending/m-p/17393#M2521</link>
      <description>Applying Rambo's suggestion:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data newtable1;&lt;BR /&gt;
 array y_(5);&lt;BR /&gt;
 do i= 1 to 5;&lt;BR /&gt;
  y_(i)=i;&lt;BR /&gt;
  end;&lt;BR /&gt;
    drop i;&lt;BR /&gt;
  run;</description>
      <pubDate>Mon, 18 Oct 2010 15:12:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loops-and-name-appending/m-p/17393#M2521</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-10-18T15:12:48Z</dc:date>
    </item>
  </channel>
</rss>

