<?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: About basic array question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/890590#M351919</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214342"&gt;@randomman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;array points{3,2} (10,20,30,40,50,60);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This statement&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;creates the variables &lt;STRONG&gt;points1-points6&lt;/STRONG&gt; as an enumeration of the array name &lt;STRONG&gt;points&lt;/STRONG&gt;, because no individual varieble names are specified, and there are 6 values in the list.&lt;/LI&gt;
&lt;LI&gt;asssigns the values &lt;STRONG&gt;10-60&lt;/STRONG&gt; from the value list in the specified order,&lt;/LI&gt;
&lt;LI&gt;and arranges the variables in a two-dimensional array structure &lt;STRONG&gt;{3,2}&lt;/STRONG&gt; with 3 rows and 2 columns, where the variables are placed in row-column order.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;So the result is:&lt;BR /&gt;|--------------|---------------|&lt;BR /&gt;| points1=10&amp;nbsp; | points2=20&amp;nbsp; |&lt;BR /&gt;|--------------|---------------|&lt;BR /&gt;| &lt;FONT color="#FF0000"&gt;points3=30&lt;/FONT&gt; | points4=40 |&lt;BR /&gt;|--------------|---------------|&lt;BR /&gt;| points5=50 | points6=60&amp;nbsp; |&lt;BR /&gt;|--------------|---------------|&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;score = points{2,1};&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This statement picks the value from &lt;STRONG&gt;row 2 column 1&lt;/STRONG&gt; in the array structure, which is the value of the variable &lt;STRONG&gt;point3&lt;/STRONG&gt;, = &lt;STRONG&gt;30&lt;/STRONG&gt;.&lt;BR /&gt;So &lt;STRONG&gt;score = points{2,1}&lt;/STRONG&gt; returns the same value as &lt;STRONG&gt;score = points3&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Aug 2023 16:33:55 GMT</pubDate>
    <dc:creator>ErikLund_Jensen</dc:creator>
    <dc:date>2023-08-23T16:33:55Z</dc:date>
    <item>
      <title>About basic array question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/890543#M351901</link>
      <description>&lt;P&gt;data temp;&lt;BR /&gt;array points{3,2} (10,20,30,40,50,60);&lt;BR /&gt;score = points{2,1};&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="randomman_0-1692792813886.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/86926iF81FF0A18741A932/image-size/medium?v=v2&amp;amp;px=400" role="button" title="randomman_0-1692792813886.png" alt="randomman_0-1692792813886.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't understand why the variable names are point1-6 and the score is 30.&lt;/P&gt;&lt;P&gt;Please explain this array in detail because I'm unfamiliar with it.&lt;/P&gt;&lt;P&gt;Thank You.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 12:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/890543#M351901</guid>
      <dc:creator>randomman</dc:creator>
      <dc:date>2023-08-23T12:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: About basic array question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/890545#M351902</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214342"&gt;@randomman&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't understand why the variable names are point1-6&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In SAS lingo, the variable names are point1-point6, not point1-6. When you don't specify variable names, the ARRAY assigns the variables to have the same name as the array name, but with suffixes indicating the position within the array. If you had specifically requested the array to use specific variable names, then you get those specific variable names, such as:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array points{3,2} flintstones jetsons scoobydoo bugsbunny elmerfudd roadrunner (10,20,30,40,50,60);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I don't understand why ... the score is 30.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Perhaps this code will help you figure this out.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
array points{3,2} (10,20,30,40,50,60);
score1=points(1,1);
score2=points(1,2);
score3=points(2,1);
score4=points(2,2);
score5=points(3,1);
score6=points(3,2);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 12:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/890545#M351902</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-23T12:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: About basic array question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/890553#M351909</link>
      <description>&lt;P&gt;If you want to use different names than the automatic ones then include them in the ARRAY statement.&lt;/P&gt;
&lt;P&gt;I find it help my brain to see the pattern if I use commas between the rows and spaces between the values within the rows when specifying initial values for a 2D array.&amp;nbsp; SAS does not care if you use spaces or commas (or some combination of the two) as the delimiters between such a list of values.&lt;/P&gt;
&lt;PRE&gt;224  data test;
225  array points{3,2} r1c1 r1c2 r2c1 r2c2 r3c1 r3c2
226    (10 20
227    ,30 40
228    ,50 60)
229  ;
230  put (_all_) (=/);
231  run;


r1c1=10
r1c2=20
r2c1=30
r2c2=40
r3c1=50
r3c2=60
NOTE: The data set WORK.TEST has 1 observations and 6 variables.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 13:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/890553#M351909</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-08-23T13:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: About basic array question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/890558#M351911</link>
      <description>&lt;P&gt;Is the question why the base of the names if POINTS?&amp;nbsp; What else would it make sense to use?&lt;/P&gt;
&lt;P&gt;Is the question why are their six variables in the array?&amp;nbsp; That is because 3 times 2 is 6.&lt;/P&gt;
&lt;PRE&gt;232  data test;
233  array points[3,2] (1:6);
234  array scores[6] (1:6);
235  put (_all_) (=/);
236  run;


points1=1
points2=2
points3=3
points4=4
points5=5
points6=6
scores1=1
scores2=2
scores3=3
scores4=4
scores5=5
scores6=6
&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Aug 2023 13:29:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/890558#M351911</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-08-23T13:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: About basic array question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/890590#M351919</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214342"&gt;@randomman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;array points{3,2} (10,20,30,40,50,60);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This statement&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;creates the variables &lt;STRONG&gt;points1-points6&lt;/STRONG&gt; as an enumeration of the array name &lt;STRONG&gt;points&lt;/STRONG&gt;, because no individual varieble names are specified, and there are 6 values in the list.&lt;/LI&gt;
&lt;LI&gt;asssigns the values &lt;STRONG&gt;10-60&lt;/STRONG&gt; from the value list in the specified order,&lt;/LI&gt;
&lt;LI&gt;and arranges the variables in a two-dimensional array structure &lt;STRONG&gt;{3,2}&lt;/STRONG&gt; with 3 rows and 2 columns, where the variables are placed in row-column order.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;So the result is:&lt;BR /&gt;|--------------|---------------|&lt;BR /&gt;| points1=10&amp;nbsp; | points2=20&amp;nbsp; |&lt;BR /&gt;|--------------|---------------|&lt;BR /&gt;| &lt;FONT color="#FF0000"&gt;points3=30&lt;/FONT&gt; | points4=40 |&lt;BR /&gt;|--------------|---------------|&lt;BR /&gt;| points5=50 | points6=60&amp;nbsp; |&lt;BR /&gt;|--------------|---------------|&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;score = points{2,1};&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This statement picks the value from &lt;STRONG&gt;row 2 column 1&lt;/STRONG&gt; in the array structure, which is the value of the variable &lt;STRONG&gt;point3&lt;/STRONG&gt;, = &lt;STRONG&gt;30&lt;/STRONG&gt;.&lt;BR /&gt;So &lt;STRONG&gt;score = points{2,1}&lt;/STRONG&gt; returns the same value as &lt;STRONG&gt;score = points3&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 16:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/890590#M351919</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2023-08-23T16:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: About basic array question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/891672#M352237</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12887"&gt;@ErikLund_Jensen&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understood it "&lt;SPAN&gt;arranges the variables in a two-dimensional array structure&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;{3,2}&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;with 3 rows and 2 columns, where the variables are placed in row-column order."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;this part.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But, I didn't understand why the array looked like&amp;nbsp;structure&amp;nbsp;&lt;STRONG&gt;{1,6} &lt;/STRONG&gt;not&amp;nbsp;&lt;STRONG&gt;{3,2}&amp;nbsp;&lt;/STRONG&gt;in the result when I printed temp.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 11:25:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/891672#M352237</guid>
      <dc:creator>randomman</dc:creator>
      <dc:date>2023-08-30T11:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: About basic array question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/891675#M352239</link>
      <description>&lt;P&gt;Except in PROC IML, a 3x2 rectangular structure of data does not exist in SAS. Array elements are always in a single observation in a SAS data set. So creating an array structure of {3,2} is essentially the same data as a {1,6} array, except that (as I showed earlier), if you want to do some fancy looping, you can refer to the third element as {2,1} if you so choose to do so.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can't use a {3,2} array to refer to the next row or previous row in a data set, if that's what you were trying to do.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 11:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/891675#M352239</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-30T11:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: About basic array question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/891748#M352252</link>
      <description>&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214342"&gt;@randomman&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I understood it "&lt;SPAN&gt;arranges the variables in a two-dimensional array structure&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;{3,2}&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;with 3 rows and 2 columns, where the variables are placed in row-column order."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;this part.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But, I didn't understand why the array looked like&amp;nbsp;structure&amp;nbsp;&lt;STRONG&gt;{1,6} &lt;/STRONG&gt;not&amp;nbsp;&lt;STRONG&gt;{3,2}&amp;nbsp;&lt;/STRONG&gt;in the result when I printed temp.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The array statement does NOT "arrange" (as in physically store) variables.&amp;nbsp; It does nothing more than to provide you a handy way to refer to variables&amp;nbsp;using an index (in your case a 2-dimensional index).&amp;nbsp; Those variables could be pre-existing variables that are not even contiguous in memory or storage.&amp;nbsp; &amp;nbsp;In fact, you could assign a collection of variables to multiple arrays, with different index structures, and it wouldn't matter to the PUT statement.&amp;nbsp; The PUT statement merely finds where the variables are in storage (based on the variable name) and prints them in a sequential list.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 16:47:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/About-basic-array-question/m-p/891748#M352252</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-08-30T16:47:14Z</dc:date>
    </item>
  </channel>
</rss>

