<?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 {I,J} in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/325146#M72286</link>
    <description>&lt;P&gt;I didn't mean for it to be harsh .. just an example that (I think) contradicts&amp;nbsp;your statement. And I think the array statement, in this case, creates new storage areas that are, in fact, contiguous. Paul Dorfman is much more knowledgeable with the particulars than I am. In case you're interested, he describes it in the post/thread at:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://listserv.uga.edu/cgi-bin/wa?A2=ind1701b&amp;amp;L=SAS-L&amp;amp;O=D&amp;amp;F=P&amp;amp;X=4D432A58082FCD2383&amp;amp;P=59414" target="_blank"&gt;https://listserv.uga.edu/cgi-bin/wa?A2=ind1701b&amp;amp;L=SAS-L&amp;amp;O=D&amp;amp;F=P&amp;amp;X=4D432A58082FCD2383&amp;amp;P=59414&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder&lt;/P&gt;</description>
    <pubDate>Mon, 16 Jan 2017 22:41:58 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-01-16T22:41:58Z</dc:date>
    <item>
      <title>Array {I,J}</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/324910#M72184</link>
      <description>&lt;P&gt;hello there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question on arrays.&lt;/P&gt;&lt;P&gt;so if there is a case that a two demensional array should be used in a dataset, is there a possibility to do so.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for instance. this way is valid &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; array myarray{*} _numeric_;&lt;/P&gt;&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;set work.mydataset;&lt;/P&gt;&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; array&lt;STRONG&gt;&lt;EM&gt; yourarray{i,j} &lt;/EM&gt;&lt;/STRONG&gt;_numeric_;&lt;/P&gt;&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; do i = 1 to dim(yourarray);&lt;/P&gt;&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;do j =1 to dim(yourarray);&lt;/P&gt;&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...........sas code.....................&lt;/P&gt;&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;/P&gt;&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&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;etc.......&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;P&gt;thanks in advance. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jan 2017 20:59:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/324910#M72184</guid>
      <dc:creator>Garik</dc:creator>
      <dc:date>2017-01-15T20:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: Array {I,J}</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/325122#M72276</link>
      <description>&lt;P&gt;No, it doesn't work like that. SAS's definition of arrays is unlike most (all?) other languages. All it does is set a template over a collection of variables: there is no space allocated as such&amp;nbsp;&lt;EM&gt;by the array statement&lt;/EM&gt; (I will defend this against all comers!).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So when you define an array, you have to set the bounds of the array dimensions. When you use the&amp;nbsp;&lt;EM&gt;_numeric_&lt;/EM&gt; or&amp;nbsp;&lt;EM&gt;_char&lt;/EM&gt;_&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;special variable names, you're assigning the array in only one dimension. WIthin the brackets you can set&amp;nbsp;either the numeric bounds or, as you've done in your first example "*", to let the SAS parser pick up the bounds from metadata.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your second example won't work for two reasons:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;the array bounds&amp;nbsp;&lt;EM&gt;must&lt;/EM&gt; be numeric constants (not variables) or *.
&lt;UL&gt;
&lt;LI&gt;Even having variables&amp;nbsp;&lt;EM&gt;i&lt;/EM&gt;&amp;nbsp;and&amp;nbsp;&lt;EM&gt;j&lt;/EM&gt;&amp;nbsp;in&amp;nbsp;&lt;EM&gt;work.dataset&lt;/EM&gt;&amp;nbsp;(and having variables called that in a dataset is never a good idea!) won't work, because they're not constants.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;_numeric_&lt;/EM&gt; is inherently one-dimensional. It is &lt;EM&gt;possible&lt;/EM&gt; to treat it as multi-dimensional, but doing that would be fraught with difficulty; I would&amp;nbsp;&lt;EM&gt;never&lt;/EM&gt; recommend it because you have very little control over the order in which your variables are referenced.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2017 20:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/325122#M72276</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-01-16T20:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: Array {I,J}</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/325131#M72278</link>
      <description>&lt;P&gt;SAS can definitely have multidimensional arrays, but not the way you've stated in your code. You'd have to give an example of what you're trying to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2017 21:21:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/325131#M72278</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-01-16T21:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: Array {I,J}</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/325133#M72280</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17429"&gt;@LaurieF&lt;/a&gt;: If NO space is allocated for SAS arrays, then please explain how the following works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let n = 10 ; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;data _null_ ; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;array work w1-w&amp;amp;n (&amp;amp;n * .M); &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;put work[*] ; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;length _init_ $ %eval(8 * &amp;amp;n) ; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;_init_ = repeat (put (1, rb8.), &amp;amp;n - 1) ; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;_addw_ = addrlong (work[1]) ; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;call pokelong (_init_, _addw_, %eval(8 * &amp;amp;n)) ;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;put work[*] ; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run ; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2017 21:25:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/325133#M72280</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-01-16T21:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Array {I,J}</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/325135#M72281</link>
      <description>&lt;P&gt;Oh - that's a little harsh!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OK here goes: it's not defining variables &lt;EM&gt;in itself&lt;/EM&gt;. This is standard SAS datastep&amp;nbsp;operating procedure: in any statement, like&amp;nbsp;&lt;EM&gt;retain&lt;/EM&gt;,&amp;nbsp;&lt;EM&gt;length&lt;/EM&gt; or&amp;nbsp;&lt;EM&gt;format&lt;/EM&gt; isn't actively defining a variable. The SAS parser goes off, creates the variable where it doesn't already exist and allows the (in this case) non-executable statement to do its thing.&amp;nbsp;&lt;EM&gt;array&lt;/EM&gt; doesn't do anything differently to any other statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only time, as far as I'm concerned, that&amp;nbsp;&lt;EM&gt;array&lt;/EM&gt; defines variables is with the&amp;nbsp;&lt;EM&gt;_temporary_&amp;nbsp;&lt;/EM&gt;keyword, and even then it's still just putting a template over a piece of (possibly discontiguous) storage.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2017 21:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/325135#M72281</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-01-16T21:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: Array {I,J}</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/325146#M72286</link>
      <description>&lt;P&gt;I didn't mean for it to be harsh .. just an example that (I think) contradicts&amp;nbsp;your statement. And I think the array statement, in this case, creates new storage areas that are, in fact, contiguous. Paul Dorfman is much more knowledgeable with the particulars than I am. In case you're interested, he describes it in the post/thread at:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://listserv.uga.edu/cgi-bin/wa?A2=ind1701b&amp;amp;L=SAS-L&amp;amp;O=D&amp;amp;F=P&amp;amp;X=4D432A58082FCD2383&amp;amp;P=59414" target="_blank"&gt;https://listserv.uga.edu/cgi-bin/wa?A2=ind1701b&amp;amp;L=SAS-L&amp;amp;O=D&amp;amp;F=P&amp;amp;X=4D432A58082FCD2383&amp;amp;P=59414&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2017 22:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/325146#M72286</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-01-16T22:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Array {I,J}</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/325349#M72355</link>
      <description>&lt;P&gt;You need to declare the number of elements in a multiple dimenstion array with integers. You can't use datastep variables to do so:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array myarray ( 10,5) ; not array myarray(i,j); This will generate ERROR 22-322: Expecting an integer constant.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your declared size does not exactly meet the number of _numeric_ variables you will get an error; either "Too few variables defined for the dimension" meaning that there are not enough existing numeric variables to fill the array or "Too many variables defined for the the dimension" meaning you did not allocate enough space for all of the _numeric_ variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use&lt;/P&gt;
&lt;P&gt;Array myarray _numeric_;&lt;/P&gt;
&lt;P&gt;without problems. Use of indices to treat as a multidimensional array will be up to you to ensure that the row and column variables are as you think they are.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 17:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/325349#M72355</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-17T17:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: Array {I,J}</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/325361#M72360</link>
      <description>&lt;P&gt;Just for fun/learning, here is an example of doing what you asked.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;&amp;nbsp; input a b c d e f;&lt;BR /&gt;&amp;nbsp; cards;&lt;BR /&gt;10 11 12 13 14 15&lt;BR /&gt;1 2 3 4 5 6&lt;BR /&gt;2 4 . 8 . 12&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;&amp;nbsp; set have;&lt;BR /&gt;&amp;nbsp; array test(2,3) _numeric_;&lt;BR /&gt;&amp;nbsp; do i=1 to 2;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if i eq 1 then x=sum(test(i,1),test(i,2),test(i,3));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; else y=sum(test(i,1),test(i,2),test(i,3));&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 17:22:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-I-J/m-p/325361#M72360</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-01-17T17:22:42Z</dc:date>
    </item>
  </channel>
</rss>

