<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/array/m-p/624303#M183898</link>
    <description>&lt;P&gt;Hi Afor,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you specify array Growth {*} Jan_2018 -- Dec_2019;&lt;/P&gt;
&lt;P&gt;to SAS, you mean all the variables in the dictionary of table bls.BLS_PPI2 starting from Jan_2018 to Dec_2019&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example :&lt;/P&gt;
&lt;P&gt;data foobar;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; JAN_2018= 201801; foo=1; bar= 2; Dec_2019= 201912;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set foobar;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; array Growth {*} Jan_2018 -- Dec_2019;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; do i=1 to dim(Growth);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; put i= growth(i)=;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Am i correct if I say that an equivalent of your code without array would be something like this:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data BLS_PPI3;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set bls.BLS_PPI2;&lt;BR /&gt;&amp;nbsp; format Growth_01-Growth_24 percent10.1;&lt;BR /&gt;&amp;nbsp; keep Series_id Growth_:;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Growth_02= (FEB_2018/JAN_2018)-1;&lt;BR /&gt;&amp;nbsp; Growth_03= (MAR_2018/FEB_2018)-1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Growth_24= (DEC_2019/NOV_2019)-1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If yes, variables JAN_2018 FEB_2018 etc DEC_2019 should be in your source table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hth&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thien&lt;/P&gt;</description>
    <pubDate>Wed, 12 Feb 2020 19:16:21 GMT</pubDate>
    <dc:creator>tlt</dc:creator>
    <dc:date>2020-02-12T19:16:21Z</dc:date>
    <item>
      <title>array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array/m-p/624278#M183887</link>
      <description>&lt;P&gt;Hi everyone, I am getting an error the following error and cannot figure out why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advanced!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Alphabetic prefixes for enumerated variables (Jan_2018-Dec_2019) are different.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  bls.BLS_PPI3;
  set bls.BLS_PPI2;
  keep Series_id;
  

  array Growth {*} Jan_2018 - Dec_2019;
  format Growth_: percent10.1;
  keep Growth_:;

  array source {*}  Jan_2018 - Dec_2019;

  do _i=2 to dim(source);
    Growth[_i-1]=((source[_i-1]/source[_i])-1);
  end;

  drop _i;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Feb 2020 18:35:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array/m-p/624278#M183887</guid>
      <dc:creator>Afor910327</dc:creator>
      <dc:date>2020-02-12T18:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array/m-p/624283#M183888</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try Jan_2018 -- Dec_2019 if all these variables are in bls.BLS_PPI2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hth&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thien&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2020 18:41:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array/m-p/624283#M183888</guid>
      <dc:creator>tlt</dc:creator>
      <dc:date>2020-02-12T18:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array/m-p/624284#M183889</link>
      <description>&lt;P&gt;Hi Thien,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I keep getting the same error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;10403  data  bls.BLS_PPI3;
10404    set bls.BLS_PPI2;
10405    keep Series_id;
10406
10407
10408    array Growth {*}  Jan_2018 -- Dec_2019;
ERROR: Variable Jan_2018 cannot be found on the list of previously defined variables.
WARNING: Defining an array with zero elements.
10409    format Growth_: percent10.1;
10410    keep Growth_:;
10411
10412    array source {*}   Jan_2018 -- Dec_2019;
ERROR: Variable Jan_2018 cannot be found on the list of previously defined variables.
WARNING: Defining an array with zero elements.
10413
10414    do _i=2 to dim(source);
10415      Growth[_i-1]=((source[_i-1]/source[_i])-1);
10416    end;
10417
10418    drop _i;
10419  run;

WARNING: The variable Growth_: in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set BLS.BLS_PPI3 may be incomplete.  When this step was stopped there were 0
         observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.11 seconds
      cpu time            0.04 seconds


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Feb 2020 18:45:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array/m-p/624284#M183889</guid>
      <dc:creator>Afor910327</dc:creator>
      <dc:date>2020-02-12T18:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array/m-p/624286#M183890</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13620"&gt;@tlt&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try Jan_2018 -- Dec_2019 if all these variables are in bls.BLS_PPI2&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, they have to be in the data set and in the proper calendar month sequence, otherwise I don't think the array will do what the user wants it to do.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2020 18:45:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array/m-p/624286#M183890</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-12T18:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array/m-p/624289#M183891</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/105695"&gt;@Afor910327&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Thien,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I keep getting the same error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
10412    array source {*}   Jan_2018 -- Dec_2019;
ERROR: Variable Jan_2018 cannot be found on the list of previously defined variables.

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This variable is not in your data set. Check your data set.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2020 18:47:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array/m-p/624289#M183891</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-12T18:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array/m-p/624293#M183893</link>
      <description>&lt;P&gt;I did all that Paige, and still does not come right. I found out though that the variable name had two under score __ instead of one, so I changed that. Nevertheless, I keep getting the same error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;34
35   data  bls.BLS_PPI3;
36     set bls.BLS_PPI2;
37     keep Series_id;
38
39
40     array Growth {*} Jan__2018-Dec__2019;
ERROR: Alphabetic prefixes for enumerated variables (Jan__2018-Dec__2019) are different.
WARNING: Defining an array with zero elements.
41     format Growth_: percent10.1;
42     keep Growth_:;
43
44     array source {*} Jan__2018-Dec__2019;
ERROR: Alphabetic prefixes for enumerated variables (Jan__2018-Dec__2019) are different.
WARNING: Defining an array with zero elements.
45
46     do _i=2 to dim(source);
47       Growth[_i-1]=((source[_i-1]/source[_i])-1);
48     end;
49
50     drop _i;
51   run;

WARNING: The variable Growth_: in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set BLS.BLS_PPI3 may be incomplete.  When this step was stopped there were 0
         observations and 1 variables.
WARNING: Data set BLS.BLS_PPI3 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.04 seconds



&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Feb 2020 18:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array/m-p/624293#M183893</guid>
      <dc:creator>Afor910327</dc:creator>
      <dc:date>2020-02-12T18:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array/m-p/624303#M183898</link>
      <description>&lt;P&gt;Hi Afor,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you specify array Growth {*} Jan_2018 -- Dec_2019;&lt;/P&gt;
&lt;P&gt;to SAS, you mean all the variables in the dictionary of table bls.BLS_PPI2 starting from Jan_2018 to Dec_2019&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example :&lt;/P&gt;
&lt;P&gt;data foobar;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; JAN_2018= 201801; foo=1; bar= 2; Dec_2019= 201912;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set foobar;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; array Growth {*} Jan_2018 -- Dec_2019;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; do i=1 to dim(Growth);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; put i= growth(i)=;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Am i correct if I say that an equivalent of your code without array would be something like this:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data BLS_PPI3;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set bls.BLS_PPI2;&lt;BR /&gt;&amp;nbsp; format Growth_01-Growth_24 percent10.1;&lt;BR /&gt;&amp;nbsp; keep Series_id Growth_:;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Growth_02= (FEB_2018/JAN_2018)-1;&lt;BR /&gt;&amp;nbsp; Growth_03= (MAR_2018/FEB_2018)-1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Growth_24= (DEC_2019/NOV_2019)-1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If yes, variables JAN_2018 FEB_2018 etc DEC_2019 should be in your source table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hth&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thien&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2020 19:16:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array/m-p/624303#M183898</guid>
      <dc:creator>tlt</dc:creator>
      <dc:date>2020-02-12T19:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array/m-p/624317#M183901</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I am unclear on 2 things:&lt;/P&gt;
&lt;P&gt;1) Why do you show the SAME variables for both the GROWTH array and the SOURCE array??? That doesn't make sense to me:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="same_var_2_arrays.png" style="width: 500px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36079i2843F69C78DAA39B/image-size/large?v=v2&amp;amp;px=999" role="button" title="same_var_2_arrays.png" alt="same_var_2_arrays.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) I believe the "double dash" method will work. Where you are getting errors, the ARRAY statement still shows just a single dash in the ARRAY statement. Here's a revised example with a simplified calculation and using just 3 months and showing the difference between the single dash and the double dash in the ARRAY definition:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="show_double_dash.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36080i104C7561A0D0A348/image-size/large?v=v2&amp;amp;px=999" role="button" title="show_double_dash.png" alt="show_double_dash.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An "enumerated" variable is like VAR1, VAR2, VAR3, VAR4, VAR5. In that case, when you have VAR1-VAR5 in the ARRAY statement, the "enumerated" variable has the SAME alphabetic prefix ("VAR") and the number at the end is different. The single dash implies to SAS that your variable list here: VAR1-VAR5 is referring to the whole list of numbered variables. But your array members do not have a common alphabetic prefix with a changing number at the end of the variable name. The double dash will tell SAS to build a list from the PDV of the variables (any variables) that are organized between the starting variable and the ending variable in your list. This may or may not be what you want, depending on how the items are stored in the PDV.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2020 19:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array/m-p/624317#M183901</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2020-02-12T19:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array/m-p/624332#M183910</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/105695"&gt;@Afor910327&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I did all that Paige, and still does not come right. I found out though that the variable name had two under score __ instead of one, so I changed that. Nevertheless, I keep getting the same error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;34
35   data  bls.BLS_PPI3;
36     set bls.BLS_PPI2;
37     keep Series_id;
38
39
40     array Growth {*} Jan__2018-Dec__2019;
ERROR: Alphabetic prefixes for enumerated variables (Jan__2018-Dec__2019) are different.

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You need&lt;/P&gt;
&lt;PRE&gt;Jan__2018--Dec__2019&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Feb 2020 20:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array/m-p/624332#M183910</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-12T20:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array/m-p/624340#M183912</link>
      <description>&lt;P&gt;Thank you so much Cynthia, the problem now is that I cannot get the growth rates, but everything seems to be better than before:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: There were 26 observations read from the data set BLS.BLS_PPI3.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           22.25 seconds
      cpu time            1.32 seconds


282  data  bls.BLS_PPI3;
283    set bls.BLS_PPI2;
284    keep Series_id;
285
286
287  array Growth {*} Jan_2018 -- Dec_2019;
288    format Growth_: percent10.1;
289    keep Growth_:;
290
291  array source {*} Jan_2018 -- Dec_2019;
292    do _i= 2 to dim(source);
293      Growth[_i-1]=((source[_i-1]/source[_i])-1);
294    end;
295
296    drop _i;
297  run;

WARNING: The variable Growth_: in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 26 observations read from the data set BLS.BLS_PPI2.
NOTE: The data set BLS.BLS_PPI3 has 26 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.12 seconds
      cpu time            0.04 seconds


298
299
300   proc print data = bls.BLS_PPI3;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Feb 2020 20:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array/m-p/624340#M183912</guid>
      <dc:creator>Afor910327</dc:creator>
      <dc:date>2020-02-12T20:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array/m-p/624364#M183920</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/105695"&gt;@Afor910327&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you so much Cynthia, the problem now is that I cannot get the growth rates, but everything seems to be better than before:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
288   &lt;FONT size="5"&gt;&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt; format Growth_: percent10.1;
289    keep Growth_:;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The code above &lt;STRONG&gt;is not referencing the array.&lt;/STRONG&gt; It creates a new variable Growth_. Which is never referenced anywhere else in your code. So you get the "never been referenced" warning. If you want to assign a format to the variables in an array then you list the variables, not the array name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Purple code is using another named array with the same variable. If you need to reference the same variables then use the same array. Mixing arrays containing the same variables is a path to madness when trying to debug what is going on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to say I am not sure how that calculates growth rate. I would tend to think you would want something like (current value -previous value) / previous value.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 15:50:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array/m-p/624364#M183920</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-02-13T15:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array/m-p/624370#M183922</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt;The issue is that Growth is the name of the array. It does NOT belong in the KEEP statement. The variables are named Jan__2018, Feb__2018, Mar__2018, etc. Growth is just a convenient reference for the ARRAY.&lt;BR /&gt;&lt;BR /&gt;Basically, an ARRAY statement is a way to reference a group of variables. I could have these variables: var1, var2, var3, var4 listed as members of an array. OR, I could have these variables -- differently named: fred, ethel, lucy, ricky listed as members of an array. &lt;BR /&gt;&lt;BR /&gt;The ARRAY name that you use is only available INSIDE the DATA step for referencing. The ARRAY name does NOT exist as a variable name. Therefore, it cannot be used in a drop or keep statement.&lt;BR /&gt;&lt;BR /&gt;Here are some simple examples of using an ARRAY name with differently named variables and same named variables:&lt;BR /&gt;&lt;BR /&gt;1) Declare an array, but do NOT use it:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="declare_not_use.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36086i67378C445527746A/image-size/large?v=v2&amp;amp;px=999" role="button" title="declare_not_use.png" alt="declare_not_use.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;2) Declare an array and use it:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="declare_and_use_array.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36087i59C13C97FD41547A/image-size/large?v=v2&amp;amp;px=999" role="button" title="declare_and_use_array.png" alt="declare_and_use_array.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Note in the above example that I can use the variable names in the KEEP, but CANNOT use the ARRAY name in the KEEP.&lt;BR /&gt;&lt;BR /&gt;3) Declare an array and use same prefix name for the numbered variables:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="use_numbered_vars.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36088i254249A171AB3BDA/image-size/large?v=v2&amp;amp;px=999" role="button" title="use_numbered_vars.png" alt="use_numbered_vars.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I don't have any DO loops in my program. I am just showing that the ARRAY name in this example (TVSHOW) is being used to declare an array "reference", where 4 actual data set variables are being declared as array members. The array name is NOT a permanent data construct. The array name is never written to the output data set. The array name is NOT a variable name.&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;BR /&gt;Cynthia&lt;BR /&gt;&lt;BR /&gt;ps. I find this paper about using ARRAYS to be very useful: &lt;A href="https://support.sas.com/rnd/papers/sgf07/arrays1780.pdf" target="_blank" rel="noopener"&gt;https://support.sas.com/rnd/papers/sgf07/arrays1780.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2020 23:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array/m-p/624370#M183922</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2020-02-12T23:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array/m-p/624384#M183928</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here's one last example that uses both an ARRAY and a DO loop in the program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Notice that COST1-COST3 and PRICE1-PRICE3 are available for each PARTNUM. I need to calculate some new variables called PROF1-PROF3. The calculation will be:&lt;/P&gt;
&lt;P&gt;PROF variable value = PRICE variable value - COST variable value;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; But, if I declare a "MAKECOST" array to have COST1-COST3 as members; and I declare a "SELLFOR" array to have PRICE1-PRICE3 as members, then I can create 3 new variables, PROF1-PROF3 as shown below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="array_and_do.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36089iEBC5787020024EAE/image-size/large?v=v2&amp;amp;px=999" role="button" title="array_and_do.png" alt="array_and_do.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The BALANCE array is declared to have PROF1-PROF3 as members. One of the neat things about ARRAYs in SAS is that if the member names do not exist, SAS will create them in the Program Data Vector (PDV). So, PROF1-PROF3 are created inside the DO loop using the ARRAY references to point to each variable. But the variable names in the output data set WIDGETS are PARTNUM, COST1-COST3, PRICE1-PRICE3 and PROF1-PROF3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; However, if I do NOT list any variables on the ARRAY statement, as shown in the program below (using SAME data as previous program):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vars_named_like_array.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36090i28BBDBF66A06962C/image-size/large?v=v2&amp;amp;px=999" role="button" title="vars_named_like_array.png" alt="vars_named_like_array.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then SAS will make me 3 numbered variables named BALANCE1, BALANCE2 and BALANCE3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 00:35:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array/m-p/624384#M183928</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2020-02-13T00:35:16Z</dc:date>
    </item>
  </channel>
</rss>

