<?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: Array help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-help/m-p/298681#M62848</link>
    <description>&lt;P&gt;&lt;SPAN class="token statement"&gt;These two lines assign all of the variables whose names start with a_ or mob_ to the array. The : immediately after characters of a variable name create a variable list that includes all those variables. Basically short hand so you don't have to write out 5, 10 or 100 variables.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; a_ a_:&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; mob_ mob_:&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;The DO loop that you omit repeat calculations for each of the variables in the AM array. There is basically an unstated array index, _i_, that would match things up. Since the MOB_ array want to use different values for the calculation other than the matching index number the value calculated inside the parantheses is used to "match up" the desired MOB_ varaibel with A_.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;am&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;a_&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;mob_&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;_i_&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;tob&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;another way to write things explicitly (and the possible confusion is one reason SAS no long recommends the Do Over construct)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;do _i_ = 1 to dim(am);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&amp;nbsp;&amp;nbsp; am(_i_)&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;a_(_i_) &lt;SPAN class="token operator"&gt;* &lt;/SPAN&gt;mob_ &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;_i_&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;tob&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token punctuation"&gt;end;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Sep 2016 15:19:34 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-09-15T15:19:34Z</dc:date>
    <item>
      <title>Array help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-help/m-p/298434#M62763</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the below data set&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; Accounts $ TOB A_1 A_2 A_3 A_4 A_5 MOB_1 MOB_2 MOB_3 MOB_4 MOB_5 MOB_6 MOB_7 MOB_8 MOB_9 MOB_10;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;cards&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;A1 3 0.01 0.012 0.013 0.0147 0.0162 0.55556 0.77778 1 1.22222 1.44444 1.44444 1.44444 1.44444 1.44444 1.44444&lt;/P&gt;&lt;P&gt;A2 2 0.012 0.0122 0.0124 0.0126 0.0128 0.9375 0.96875 1 1.03125 1.0625 1.0625 1.0625 1.0625 1.0625 1.0625&lt;/P&gt;&lt;P&gt;A3 4 0.013 0.016 0.019 0.022 0.025 0.77778 0.88889 1 1.11111 1.22222 1.22222 1.22222 1.22222 1.22222 1.22222&lt;/P&gt;&lt;P&gt;A4 1 0.014 0.0143 0.0146 0.0149 0.0152 0.97561 0.9878 1 1.0122 1.02439 1.02439 1.02439 1.02439 1.02439 1.02439&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;run&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;I need to multiply information based on the second column which is TOB, if TOB is&amp;nbsp;3 then resulting table should start multiplying the A_1 to MoB_3 and after that A_2 with A_4 and so on.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Another example for Account A2&amp;nbsp;has TOB is 2 then A_1 multiply with MoB_2, A2*Mob_3 and so on.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;For more detail follow the attached excel file&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Thank you so much in advance.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 20:13:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-help/m-p/298434#M62763</guid>
      <dc:creator>umesh1</dc:creator>
      <dc:date>2016-09-14T20:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: Array help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-help/m-p/298435#M62764</link>
      <description>&lt;P&gt;Not sure if this is what you have in mind:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;

input Accounts $ TOB A_1 A_2 A_3 A_4 A_5 MOB_1 MOB_2 MOB_3 MOB_4 MOB_5 MOB_6 MOB_7 MOB_8 MOB_9 MOB_10;

cards;
A1 3 0.01 0.012 0.013 0.0147 0.0162 0.55556 0.77778 1 1.22222 1.44444 1.44444 1.44444 1.44444 1.44444 1.44444
A2 2 0.012 0.0122 0.0124 0.0126 0.0128 0.9375 0.96875 1 1.03125 1.0625 1.0625 1.0625 1.0625 1.0625 1.0625
A3 4 0.013 0.016 0.019 0.022 0.025 0.77778 0.88889 1 1.11111 1.22222 1.22222 1.22222 1.22222 1.22222 1.22222
A4 1 0.014 0.0143 0.0146 0.0149 0.0152 0.97561 0.9878 1 1.0122 1.02439 1.02439 1.02439 1.02439 1.02439 1.02439
;
run;

data want;
set test;
array am am1-am5;
array a_ a_:;
array mob_ mob_:;
do over am;
am=a_*mob_(_i_+tob-1);
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Sep 2016 20:27:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-help/m-p/298435#M62764</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-09-14T20:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Array help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-help/m-p/298671#M62841</link>
      <description>&lt;P&gt;Haikyo, This was very helpful from my learning perspective. Thanks. I'm little unsure about&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; a_ a_:&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; mob_ mob_:&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;am=a_*mob_(_i_+tob-1);&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What does these 3 line codes mean and during what kind of situations u use this? &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2016 15:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-help/m-p/298671#M62841</guid>
      <dc:creator>devsas</dc:creator>
      <dc:date>2016-09-15T15:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Array help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-help/m-p/298681#M62848</link>
      <description>&lt;P&gt;&lt;SPAN class="token statement"&gt;These two lines assign all of the variables whose names start with a_ or mob_ to the array. The : immediately after characters of a variable name create a variable list that includes all those variables. Basically short hand so you don't have to write out 5, 10 or 100 variables.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; a_ a_:&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; mob_ mob_:&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;The DO loop that you omit repeat calculations for each of the variables in the AM array. There is basically an unstated array index, _i_, that would match things up. Since the MOB_ array want to use different values for the calculation other than the matching index number the value calculated inside the parantheses is used to "match up" the desired MOB_ varaibel with A_.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;am&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;a_&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;mob_&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;_i_&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;tob&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;another way to write things explicitly (and the possible confusion is one reason SAS no long recommends the Do Over construct)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;do _i_ = 1 to dim(am);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&amp;nbsp;&amp;nbsp; am(_i_)&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;a_(_i_) &lt;SPAN class="token operator"&gt;* &lt;/SPAN&gt;mob_ &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;_i_&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;tob&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token punctuation"&gt;end;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2016 15:19:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-help/m-p/298681#M62848</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-15T15:19:34Z</dc:date>
    </item>
  </channel>
</rss>

