<?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: 2 dimensional macro array in loop (%do) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/2-dimensional-macro-array-in-loop-do/m-p/300773#M312327</link>
    <description>&lt;P&gt;This is likely the wrong assignment for someone who is relatively new to SAS.&amp;nbsp; DATA steps permit 2D arrays.&amp;nbsp; Macros really don't support arrays at all.&amp;nbsp; So check with a local SAS programmer to see that this is the right approach for the problem you are trying to solve.&amp;nbsp; At any rate, you can simulate an array in macro language by using naming conventions for your macro variables.&amp;nbsp; For example, you could add this statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let val_&amp;amp;row._&amp;amp;col. = &amp;amp;value;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That might replace the %PUT statement (which would likely have to be changed anyway, since there is nothing in this code that creates &amp;amp;MYCOL).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At the end of this, at least for testing purposes, you might want to see what you have created, by adding:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put _user_;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Sep 2016 14:54:55 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-09-26T14:54:55Z</dc:date>
    <item>
      <title>2 dimensional macro array in loop (%do)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/2-dimensional-macro-array-in-loop-do/m-p/300768#M312326</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to declare a&amp;nbsp;&amp;nbsp;2D &lt;STRONG&gt;macro&lt;/STRONG&gt; array before the following code and fill the partucular elements of the array with some value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%do ii=1 %to &amp;amp;countlnt;&lt;BR /&gt;%let row = %eval(%scan(&amp;amp;myw,&amp;amp;ii , *)); &amp;nbsp;&lt;STRONG&gt; --&amp;gt; this will be the row of the macro array&lt;/STRONG&gt;&lt;BR /&gt;%let col = %eval(%scan(&amp;amp;myy,&amp;amp;ii , *)-&amp;amp;currentYear+11); &amp;nbsp;&lt;STRONG&gt;--&amp;gt; this will be the column of the&amp;nbsp;macro array&lt;/STRONG&gt;&lt;BR /&gt;%let value = %eval(%scan(&amp;amp;mycount,&amp;amp;ii , *)); &amp;nbsp;&lt;STRONG&gt;--&amp;gt; and this is the value for the cell (row,col)&lt;/STRONG&gt;&lt;BR /&gt;%put &amp;amp;mycol ;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am very new in SAS. I would really be appriciated if somebody help me. Thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2016 14:39:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/2-dimensional-macro-array-in-loop-do/m-p/300768#M312326</guid>
      <dc:creator>samira</dc:creator>
      <dc:date>2016-09-26T14:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: 2 dimensional macro array in loop (%do)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/2-dimensional-macro-array-in-loop-do/m-p/300773#M312327</link>
      <description>&lt;P&gt;This is likely the wrong assignment for someone who is relatively new to SAS.&amp;nbsp; DATA steps permit 2D arrays.&amp;nbsp; Macros really don't support arrays at all.&amp;nbsp; So check with a local SAS programmer to see that this is the right approach for the problem you are trying to solve.&amp;nbsp; At any rate, you can simulate an array in macro language by using naming conventions for your macro variables.&amp;nbsp; For example, you could add this statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let val_&amp;amp;row._&amp;amp;col. = &amp;amp;value;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That might replace the %PUT statement (which would likely have to be changed anyway, since there is nothing in this code that creates &amp;amp;MYCOL).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At the end of this, at least for testing purposes, you might want to see what you have created, by adding:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put _user_;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2016 14:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/2-dimensional-macro-array-in-loop-do/m-p/300773#M312327</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-26T14:54:55Z</dc:date>
    </item>
  </channel>
</rss>

