<?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: Understanding Array function with a do loop and first. in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581571#M28531</link>
    <description>The triangular output is useless. This method is usually used in conjunction with LAST to keep only the last record of each group, which is essentially a transpose. The rationale for using this type of approach is when you need to restructure multiple variables at a time that would mean multiple calls to PROC TRANSPOSE + MERGE and/or wanting to calculate other statistics in the same step to avoid multiple passes of the data.</description>
    <pubDate>Thu, 15 Aug 2019 19:10:13 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-08-15T19:10:13Z</dc:date>
    <item>
      <title>Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581523#M28523</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to understand the array functionality within the context of do loop. However, in the following code, I am running into difficulty understanding how the array is being repleted with sequential values:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is from IDRE website. This code produces the dataset which is used in the next section.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;data long_array;
  set wide;
  array Afaminc(96:98) faminc96 - faminc98;
  do year = 96 to 98;
   faminc = Afaminc[year];
   output;
  end;
  drop faminc96-faminc98;
run;
proc print data=long_array;
run;&lt;/STRONG&gt;

Obs    famid    year    faminc
 1       1       96      40000
 2       1       97      40500
 3       1       98      41000
 4       2       96      45000
 5       2       97      45400
 6       2       98      45800
 7       3       96      75000
 8       3       97      76000
 9       3       98      77000&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is where I am having difficulty:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;proc sort data=long_array out=long_sort;
  by famid;
run;
data wide_array;
  set long_sort;
  by famid;
  retain faminc96-faminc98;
  array Afaminc(96:98) faminc96-faminc98;
  if first.famid then do;
    do i = 96 to 98;
      Afaminc[i] = .; /*initializing to missing*/
    end;
  end;
  Afaminc(year) = faminc; &lt;/STRONG&gt;/*looping across values in the variable year*/&lt;STRONG&gt;  *if last.famid then output; &lt;/STRONG&gt;/* outputs only the last obs in a family*/&lt;STRONG&gt;  drop year faminc i;
run;
proc print data=wide_array noobs;
run;&lt;/STRONG&gt;

famid    faminc96    faminc97    faminc98
  1        40000           .           .
  1        40000       40500           .
  1        40000       40500       41000
  2        45000           .           .
  2        45000       45400           .
  2        45000       45400       45800
  3        75000           .           .
  3        75000       76000           .
  3        75000       76000       77000&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;specifically for this code snippet:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;  retain faminc96-faminc98;
  array Afaminc(96:98) faminc96-faminc98;
  if first.famid then do;
    do i = 96 to 98;
      Afaminc[i] = .; /*initializing to missing*/
    end;
  end;
  Afaminc(year) = faminc; &lt;/STRONG&gt;/*looping across values in the variable year*/&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so I understand that the retain statement is for faminc96-faminc98 by assigning default values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;However, in the array Afaminc(96:98)&amp;nbsp; when we assign those variables, they are still having missing values -- so why are we&amp;nbsp; again assigning "."&amp;nbsp; as commented in&amp;nbsp; /*initializing to missing*/&amp;nbsp; in the do loop?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;famid&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;year&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;faminc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;faminc96&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;faminc97&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;faminc98&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;96&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;40000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;97&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;40500&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;98&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;41000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;96&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;45000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;97&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;45400&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;98&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;45800&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;96&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;75000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;97&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;76000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;98&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;77000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Second, what are we looping over in the Afaminc[i]&amp;nbsp; expression?&amp;nbsp; If this is by array index, then are we going over Afaminc[96]&amp;nbsp; which is actually the faminc96?&lt;/LI&gt;&lt;LI&gt;Third, what is exactly &lt;STRONG&gt;&lt;I&gt;if first.famid then do &lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;the purpose in this -- does that mean only for the first observation for famid, it will loop over 96 to 98? In some other SAS documents, it only uses do one time but here we have done twice --why? see this example:&amp;nbsp;&lt;PRE&gt;&lt;STRONG&gt;DATA sum5 ;
 SET kids ;
  BY famid ;
 
  RETAIN sumwt cnt ;
 
  IF first.famid THEN
   DO;
    sumwt = 0;
    cnt   = 0;
   END;
 
  sumwt = sumwt + wt ;
  cnt = cnt + 1 ;
  meanwt = sumwt / cnt ;
 
  IF last.famid THEN OUTPUT;
 
  KEEP famid sumwt cnt meanwt ;
 
RUN;&lt;/STRONG&gt;&lt;/PRE&gt;&lt;/LI&gt;&lt;LI&gt;****&lt;STRONG&gt;&lt;EM&gt;&lt;U&gt;And lastly, this is the most challenging part so far&lt;/U&gt;&lt;/EM&gt;&lt;/STRONG&gt;. The &lt;STRONG&gt;Afaminc(year) = faminc; &lt;/STRONG&gt;/*looping across values in the variable year*/ this actually fills out the empty array in a specific format which I was not quite able to follow. The looping mechanism is not very explicitly understood, however, it seems to have filled out the array in a specific pattern which I am having difficulty understanding.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;famid&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;year&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;faminc&lt;/STRONG&gt;&lt;/P&gt;&l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t;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would greatly appreciate if someone could point me towards the right resource or elaborate this code with a bit more background example/explanation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 17:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581523#M28523</guid>
      <dc:creator>sigma_exp</dc:creator>
      <dc:date>2019-08-15T17:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581535#M28524</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;However, in the array Afaminc(96:98)&amp;nbsp; when we assign those variables, they are still having missing values -- so why are we&amp;nbsp; again assigning "."&amp;nbsp; as commented in&amp;nbsp; /*initializing to missing*/&amp;nbsp; in the do loop?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It would appear that the array statement fills in missings for the first value of famid, and then the RETAIN causes the missings to be filled in on other records. You really don't need RETAIN, DO and FIRST. here, this is overkill.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Second, what are we looping over in the Afaminc[i]&amp;nbsp; expression?&amp;nbsp; If this is by array index, then are we going over Afaminc[96]&amp;nbsp; which is actually the faminc96?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yes&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Third, what is exactly&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;if first.famid then do&amp;nbsp;&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;the purpose in this -- does that mean only for the first observation for famid, it will loop over 96 to 98? In some other SAS documents, it only uses do one time but here we have done twice --why?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yes, and then the RETAIN statement will fill in missings. As I said, a very redundant and inefficient way of programming.&lt;/SPAN&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;U&gt;And lastly, this is the most challenging part so far&lt;/U&gt;&lt;/EM&gt;&lt;/STRONG&gt;. The&amp;nbsp;&lt;STRONG&gt;Afaminc(year) = faminc;&amp;nbsp;&lt;/STRONG&gt;/*looping across values in the variable year*/ this actually fills out the empty array in a specific format which I was not quite able to follow. The looping mechanism is not very explicitly understood, however, it seems to have filled out the array in a specific pattern which I am having difficulty understanding.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;it is creating the "triangular" array of data that is shown. Afaminc(year) takes the value of each year, and the assigns the value of FAMINC to that element of the array. Again, this seems like a very convoluted way to program things.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 17:54:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581535#M28524</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-15T17:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581539#M28525</link>
      <description>Isn't first here resetting the array for each BY group. The first example doesn't need that because it's a single ID, but if you have more than one ID and are using RETAIN you have to reset them?</description>
      <pubDate>Thu, 15 Aug 2019 18:03:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581539#M28525</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-15T18:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581548#M28526</link>
      <description>&lt;PRE&gt;*holds values across rows; 
 retain faminc96-faminc98;
*note the 96:98 which creates the index for the variables rather than 1:3, this way you can refer to it using the two digit year which is in the data set;
  array Afaminc(96:98) faminc96-faminc98;

*resets the array to missing for the start of new ids;
*you could combine the do loop here but not a huge deal;
  if first.famid then do;
    do i = 96 to 98;
      Afaminc[i] = .; /*initializing to missing*/
    end;
  end;

  *assigns value to the proper varialbe in the array using year as the index;
  *There is NO LOOP HERE;
  Afaminc(year) = faminc;&lt;/PRE&gt;
&lt;P&gt;See my comments in the code above.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The UCLA tutorial on arrays itself is helpful here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-arrays/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-arrays/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/284713"&gt;@sigma_exp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to understand the array functionality within the context of do loop. However, in the following code, I am running into difficulty understanding how the array is being repleted with sequential values:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is from IDRE website. This code produces the dataset which is used in the next section.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;data long_array;
  set wide;
  array Afaminc(96:98) faminc96 - faminc98;
  do year = 96 to 98;
   faminc = Afaminc[year];
   output;
  end;
  drop faminc96-faminc98;
run;
proc print data=long_array;
run;&lt;/STRONG&gt;

Obs    famid    year    faminc
 1       1       96      40000
 2       1       97      40500
 3       1       98      41000
 4       2       96      45000
 5       2       97      45400
 6       2       98      45800
 7       3       96      75000
 8       3       97      76000
 9       3       98      77000&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is where I am having difficulty:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;proc sort data=long_array out=long_sort;
  by famid;
run;
data wide_array;
  set long_sort;
  by famid;
  retain faminc96-faminc98;
  array Afaminc(96:98) faminc96-faminc98;
  if first.famid then do;
    do i = 96 to 98;
      Afaminc[i] = .; /*initializing to missing*/
    end;
  end;
  Afaminc(year) = faminc; &lt;/STRONG&gt;/*looping across values in the variable year*/&lt;STRONG&gt;  *if last.famid then output; &lt;/STRONG&gt;/* outputs only the last obs in a family*/&lt;STRONG&gt;  drop year faminc i;
run;
proc print data=wide_array noobs;
run;&lt;/STRONG&gt;

famid    faminc96    faminc97    faminc98
  1        40000           .           .
  1        40000       40500           .
  1        40000       40500       41000
  2        45000           .           .
  2        45000       45400           .
  2        45000       45400       45800
  3        75000           .           .
  3        75000       76000           .
  3        75000       76000       77000&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;specifically for this code snippet:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;  retain faminc96-faminc98;
  array Afaminc(96:98) faminc96-faminc98;
  if first.famid then do;
    do i = 96 to 98;
      Afaminc[i] = .; /*initializing to missing*/
    end;
  end;
  Afaminc(year) = faminc; &lt;/STRONG&gt;/*looping across values in the variable year*/&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so I understand that the retain statement is for faminc96-faminc98 by assigning default values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;However, in the array Afaminc(96:98)&amp;nbsp; when we assign those variables, they are still having missing values -- so why are we&amp;nbsp; again assigning "."&amp;nbsp; as commented in&amp;nbsp; /*initializing to missing*/&amp;nbsp; in the do loop?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;famid&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;year&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;faminc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;faminc96&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;faminc97&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;faminc98&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;96&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;40000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;97&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;40500&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;98&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;41000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;96&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;45000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;97&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;45400&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;98&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;45800&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;96&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;75000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;97&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;76000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;98&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;77000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Second, what are we looping over in the Afaminc[i]&amp;nbsp; expression?&amp;nbsp; If this is by array index, then are we going over Afaminc[96]&amp;nbsp; which is actually the faminc96?&lt;/LI&gt;
&lt;LI&gt;Third, what is exactly &lt;STRONG&gt;&lt;I&gt;if first.famid then do &lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;the purpose in this -- does that mean only for the first observation for famid, it will loop over 96 to 98? In some other SAS documents, it only uses do one time but here we have done twice --why? see this example:&amp;nbsp;
&lt;PRE&gt;&lt;STRONG&gt;DATA sum5 ;
 SET kids ;
  BY famid ;
 
  RETAIN sumwt cnt ;
 
  IF first.famid THEN
   DO;
    sumwt = 0;
    cnt   = 0;
   END;
 
  sumwt = sumwt + wt ;
  cnt = cnt + 1 ;
  meanwt = sumwt / cnt ;
 
  IF last.famid THEN OUTPUT;
 
  KEEP famid sumwt cnt meanwt ;
 
RUN;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;****&lt;STRONG&gt;&lt;EM&gt;&lt;U&gt;And lastly, this is the most challenging part so far&lt;/U&gt;&lt;/EM&gt;&lt;/STRONG&gt;. The &lt;STRONG&gt;Afaminc(year) = faminc; &lt;/STRONG&gt;/*looping across values in the variable year*/ this actually fills out the empty array in a specific format which I was not quite able to follow. The looping mechanism is not very explicitly understood, however, it seems to have filled out the array in a specific pattern which I am having difficulty understanding.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;famid&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;year&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;faminc&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;faminc96&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;faminc97&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;faminc98&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;STRONG&gt;i&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt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;nbsp;&lt;/P&gt;
&lt;P&gt;I would greatly appreciate if someone could point me towards the right resource or elaborate this code with a bit more background example/explanation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;/LI-SPOILER&gt;</description>
      <pubDate>Thu, 15 Aug 2019 18:20:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581548#M28526</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-15T18:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581550#M28527</link>
      <description>&lt;P&gt;Thank you very much Paige for the detailed reply. I am following through most of what you have explained. However, there is the last section that a bit more explanation might be great. For example,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"&lt;SPAN&gt;it is creating the "triangular" array of data that is shown. Afaminc(year) takes the value of each year, and the assigns the value of FAMINC to that element of the array. Again, this seems like a very convoluted way to program things."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So, Afaminc(year), let take year=96. Then the corresponding faminc value for famid=1 is 40000. Now, when it assigns the "value of FAMINC to that element of the array" -- is that &lt;STRONG&gt;Afaminc(96) &lt;/STRONG&gt;[since "&lt;STRONG&gt;&lt;EM&gt;i&lt;/EM&gt;"&amp;nbsp;&lt;/STRONG&gt;in the first iteration is 96, which actually&amp;nbsp;&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;faminc96&lt;/STRONG&gt;&lt;/EM&gt;]&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and then how exactly are these "triangular" array of data being generated in that loop.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If it is not too taxing, would you please consider giving a small snippet based example of what would better way to achieve the same where it is programmatically not so distorted (sorry for using that term, but it was really giving me such hard time!).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you again,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 18:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581550#M28527</guid>
      <dc:creator>sigma_exp</dc:creator>
      <dc:date>2019-08-15T18:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581556#M28528</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/284713"&gt;@sigma_exp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you very much Paige for the detailed reply. I am following through most of what you have explained. However, there is the last section that a bit more explanation might be great. For example,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;it is creating the "triangular" array of data that is shown. Afaminc(year) takes the value of each year, and the assigns the value of FAMINC to that element of the array. Again, this seems like a very convoluted way to program things."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So, Afaminc(year), let take year=96. Then the corresponding faminc value for famid=1 is 40000. Now, when it assigns the "value of FAMINC to that element of the array" -- is that &lt;STRONG&gt;Afaminc(96) &lt;/STRONG&gt;[since "&lt;STRONG&gt;&lt;EM&gt;i&lt;/EM&gt;"&amp;nbsp;&lt;/STRONG&gt;in the first iteration is 96, which actually&amp;nbsp;&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;faminc96&lt;/STRONG&gt;&lt;/EM&gt;]&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and then how exactly are these "triangular" array of data being generated in that loop.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;One of the variables faminc96 faminc97 faminc98 is assigned a value each time the data step works with a input record. The rest are assigned by the RETAIN statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;If it is not too taxing, would you please consider giving a small snippet based example of what would better way to achieve the same where it is programmatically not so distorted (sorry for using that term, but it was really giving me such hard time!).&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Well, let me see here:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set long_array;
    by famid;
    prev_faminc=lag(faminc);
    prev2_faminc=lag2(faminc);
    if first.famid then counter=0;
    counter+1;
    if counter=1 then faminc96=faminc;
    if counter=2 then do;
        faminc96=prev_faminc;
        faminc97=faminc;
     end;
     if counter=3 then do;
        faminc96=prev2_faminc;
        faminc97=prev_faminc;
        faminc98=faminc;
    end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Now I also want to state that I realize this is a learning exercise for you, and so the answer to the next question isn't specifically required here, but here goes ... What is the benefit of creating such a triangular arrangement of the data? I see no reason to do this, I can't think of a single analysis or display that would require such a triangular arrangement of the data.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 18:32:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581556#M28528</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-15T18:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581557#M28529</link>
      <description>&lt;P&gt;Thank you so much Reza! So probably that was a mistake in the main code w.r.t (Afaminc(year) = faminc; . However,&lt;BR /&gt;*assigns value to the proper variable in the array using the year as the index;&lt;BR /&gt;*There is NO LOOP HERE;&lt;BR /&gt;Afaminc(year) = faminc; -- how does that achieve the traingular pattern to fill out the array -- could you please elaborate&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 18:45:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581557#M28529</guid>
      <dc:creator>sigma_exp</dc:creator>
      <dc:date>2019-08-15T18:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581560#M28530</link>
      <description>ahh, the example above this one actually helps learn how it can be generated with enhanced clarity and bonus learning about the lag function. This is extremly helpful. Thank you!</description>
      <pubDate>Thu, 15 Aug 2019 18:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581560#M28530</guid>
      <dc:creator>sigma_exp</dc:creator>
      <dc:date>2019-08-15T18:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581571#M28531</link>
      <description>The triangular output is useless. This method is usually used in conjunction with LAST to keep only the last record of each group, which is essentially a transpose. The rationale for using this type of approach is when you need to restructure multiple variables at a time that would mean multiple calls to PROC TRANSPOSE + MERGE and/or wanting to calculate other statistics in the same step to avoid multiple passes of the data.</description>
      <pubDate>Thu, 15 Aug 2019 19:10:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581571#M28531</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-15T19:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581573#M28532</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/284713"&gt;@sigma_exp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you so much Reza! So probably that was a mistake in the main code w.r.t (Afaminc(year) = faminc; . However,&lt;BR /&gt;*assigns value to the proper variable in the array using the year as the index;&lt;BR /&gt;*There is NO LOOP HERE;&lt;BR /&gt;Afaminc(year) = faminc; -- how does that achieve the traingular pattern to fill out the array -- could you please elaborate&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;At each row it moves that value to the correct variable and stores all the previous values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code is correct, the COMMENT is wrong.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Year  Value  faminc96 faminc97 faminc98
96      100    100
97      101    100           101
98      102     100          101         102    &amp;lt;- keep only this record at the end with last.



&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;First pass through, the year is 96 and the value gets assigned to faminc96&lt;/P&gt;
&lt;P&gt;Second row, year is 97, value gets assigned from 97 to faminc 97 and faminc96 is still kept because of the retain&lt;/P&gt;
&lt;P&gt;Repeat until the last obs of the by group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;The data step itself is the loop here, there's no explicit do loop.&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 19:14:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581573#M28532</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-15T19:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581580#M28533</link>
      <description>okay....so it was the data step during the iteration which I was missing earlier, thank you for explaining. But in the code, it only matches to the index in the array: Afaminc(year) and corresponding faminc value gets repleted. However, how does that get matched across three other columns--faminc96 -faminc98? If SAS matches it internally, then shouldn't it either match by name or by position? But the faminc value does not meet either of them--neither it matches "faminc96" column header nor its position. The same can be said for the other two columns as well. Or is it the SAS convention to replace a value across a row (matched by index) with a specific value? I am probably missing something here.</description>
      <pubDate>Thu, 15 Aug 2019 19:49:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581580#M28533</guid>
      <dc:creator>sigma_exp</dc:creator>
      <dc:date>2019-08-15T19:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581602#M28534</link>
      <description>Year = 96, 97 and 98&lt;BR /&gt;&lt;BR /&gt;afaminc is a an array with the indexes of 96, 97 and 98 - see my first answer to you. &lt;BR /&gt;&lt;BR /&gt;so afaminc(96) -&amp;gt; is actually a short cut to faminc96&lt;BR /&gt;afaminc(97) -&amp;gt; short cut to faminc97. &lt;BR /&gt;&lt;BR /&gt;As the data step loops it moves each year into the correct position and remembers the previous values until you explicitly reset them all at the FIRST condition.  You should add a bunch of PUT statements in there in various places and see what's happening in each step if you want to trace it all through.</description>
      <pubDate>Thu, 15 Aug 2019 20:47:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581602#M28534</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-15T20:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581727#M28535</link>
      <description>okay...thanks a lot-- I will work through the %PUT and see what it does. Much appreciated Reeza for the advice</description>
      <pubDate>Fri, 16 Aug 2019 14:08:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581727#M28535</guid>
      <dc:creator>sigma_exp</dc:creator>
      <dc:date>2019-08-16T14:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581732#M28537</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;How did you generate the SPOILER thingy in your message?&amp;nbsp; Is that something the Forum editor does? If so how? Or did you manually edit the HTML?&amp;nbsp; If so what did you change?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 14:32:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581732#M28537</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-16T14:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581733#M28538</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/284713"&gt;@sigma_exp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;okay...thanks a lot-- I will work through the %PUT and see what it does. Much appreciated Reeza for the advice&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Macro %PUT is not going to be of much value with that program. It is not using any macro variables.&lt;/P&gt;
&lt;P&gt;You should the normal data step statement PUT instead. Then you can output values of the dataset variables.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 14:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581733#M28538</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-16T14:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581761#M28539</link>
      <description>Okay, thank you Tom for pointing it out... I will edit my response.</description>
      <pubDate>Fri, 16 Aug 2019 16:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581761#M28539</guid>
      <dc:creator>sigma_exp</dc:creator>
      <dc:date>2019-08-16T16:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Array function with a do loop and first.</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581783#M28542</link>
      <description>&lt;P&gt;It's in the rich text editor, it's the 5th icon. You can insert similar to a code window and then I just put what I want in there.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Usually only when it gets to be too much code or text so that the thread doesn't get unmanageable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;How did you generate the SPOILER thingy in your message?&amp;nbsp; Is that something the Forum editor does? If so how? Or did you manually edit the HTML?&amp;nbsp; If so what did you change?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 17:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-Array-function-with-a-do-loop-and-first/m-p/581783#M28542</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-16T17:11:55Z</dc:date>
    </item>
  </channel>
</rss>

