<?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: accessing variable names through loop in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/accessing-variable-names-through-loop/m-p/580447#M17758</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122002"&gt;@VDD&lt;/a&gt;&amp;nbsp;Why did you include the OUTPUT statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't tell SAS that the array has character variables when they are already defined as numeric should cause an error.&amp;nbsp; Also note there is no need to tell SAS how many elements are in the array when you have listed the names.&amp;nbsp; It will just count them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array x x1-x3;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and you don't have to count them either, use the DIM() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i=1 to dim(x);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Aug 2019 02:28:11 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-08-12T02:28:11Z</dc:date>
    <item>
      <title>accessing variable names through loop</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/accessing-variable-names-through-loop/m-p/580437#M17756</link>
      <description>&lt;P&gt;I have the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input num x1 x2 x3;&lt;BR /&gt;datalines;&lt;BR /&gt;1 . . .&lt;BR /&gt;2 . . .&lt;BR /&gt;3 . . . &lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose i want to make a multiplication table (pseudo code)&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;do i=1 to 3&lt;/P&gt;
&lt;P&gt;&amp;nbsp; x&amp;amp;i = number*i;&lt;/P&gt;
&lt;P&gt;end&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically, the variables x1-x3 contain in them information, namely, the multiplication factor, so I want using a loop to "assemble" the variable name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Aug 2019 22:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/accessing-variable-names-through-loop/m-p/580437#M17756</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2019-08-11T22:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: accessing variable names through loop</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/accessing-variable-names-through-loop/m-p/580438#M17757</link>
      <description>&lt;PRE&gt;data have;
input num x1 x2 x3;
datalines;
1 . . .
2 . . .
3 . . . 
;
run;
data want;
set have;
array x{*} $ x1-x3;
do i=1 to 3;
  x[i] = num*i;
  if i = 3 then output;
end;
run;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Aug 2019 23:31:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/accessing-variable-names-through-loop/m-p/580438#M17757</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-08-11T23:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: accessing variable names through loop</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/accessing-variable-names-through-loop/m-p/580447#M17758</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122002"&gt;@VDD&lt;/a&gt;&amp;nbsp;Why did you include the OUTPUT statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't tell SAS that the array has character variables when they are already defined as numeric should cause an error.&amp;nbsp; Also note there is no need to tell SAS how many elements are in the array when you have listed the names.&amp;nbsp; It will just count them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array x x1-x3;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and you don't have to count them either, use the DIM() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i=1 to dim(x);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2019 02:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/accessing-variable-names-through-loop/m-p/580447#M17758</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-12T02:28:11Z</dc:date>
    </item>
  </channel>
</rss>

