<?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: set IML matrix name based on the do loop, how do I do that? in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216983#M2258</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what is the generic way to automatically rename matrix name with i as post fix?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Personally I tried to avoid using call execute statement, it looks cumbersome to me, especially when code gets bigger and intertwined with other logic.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 May 2015 16:46:43 GMT</pubDate>
    <dc:creator>ZRick</dc:creator>
    <dc:date>2015-05-19T16:46:43Z</dc:date>
    <item>
      <title>set IML matrix name based on the do loop, how do I do that?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216979#M2254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp; I want to following code’s result to be y_1 = 5, y_2=5, y_3&lt;BR /&gt;=5, it didn’t give me the matrix name what I wanted. It always gives me: k_3&lt;BR /&gt;=5, k_3 = 5, k_3=5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want the matrix name to be based on the do loop k as post&lt;BR /&gt;fix. How do I do that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;iml&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New';"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt; k = &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New';"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;3&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New';"&gt;call&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt; symputx(&lt;/SPAN&gt;&lt;SPAN style="background: white; color: purple; font-family: 'Courier New';"&gt;"run_k"&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;, k);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mc_k = num(symget(&lt;/SPAN&gt;&lt;SPAN style="background: white; color: purple; font-family: 'Courier New';"&gt;"run_k"&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;));&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background: white; color: red; font-family: 'Courier New';"&gt;y_&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: teal; font-family: 'Courier New';"&gt;mc_k.&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt; = &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;5&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New';"&gt;print&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt; y_&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: teal; font-family: 'Courier New';"&gt;mc_k.&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New';"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 21:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216979#M2254</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2015-05-18T21:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: set IML matrix name based on the do loop, how do I do that?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216980#M2255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The macro variable &amp;amp;mc_k will be resolved just once at compile time, so I presume it had the value 3 before you ran the code above (the macro variable here is not the same as the matrix mc_k).&amp;nbsp; There is no need to resort to the SAS macro language as you can use call execute to get what you want.&amp;nbsp; A line of IML code can be constructed in a character matrix and then you can have IML execute it, but note that this will only work from inside a module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start yarray;&lt;BR /&gt;&amp;nbsp; yname = 'y_1' : 'y_3';&lt;BR /&gt;&amp;nbsp; do k = 1 to 3;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute( yname&lt;K&gt; + '=5;' );&lt;BR /&gt;&amp;nbsp; end;&lt;/K&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; print y_1 y_2 y_3;&lt;BR /&gt;finish;&lt;/P&gt;&lt;P&gt;run yarray;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a real application the code quickly becomes difficult to read, since every time you refer to y_k, there will be a complicated call execute statement.&amp;nbsp; In the case where all the matrices are the same size, then it may be better to store them as sub-matrices of a single large matrix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I only wish there was a better way to have an array of matrices.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 07:42:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216980#M2255</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2015-05-19T07:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: set IML matrix name based on the do loop, how do I do that?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216981#M2256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just realised that once the matrices are defined as above, it's possible to refer to them using the value function.&amp;nbsp;&amp;nbsp; So&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; x = 2 # value(yname[2]);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;would set x to 10.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 08:22:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216981#M2256</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2015-05-19T08:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: set IML matrix name based on the do loop, how do I do that?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216982#M2257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not following your code, &lt;BR /&gt; x = 2 # value(yname[2]);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you put out a complete version?&lt;/P&gt;&lt;P&gt;Thanks so much.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 16:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216982#M2257</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2015-05-19T16:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: set IML matrix name based on the do loop, how do I do that?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216983#M2258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what is the generic way to automatically rename matrix name with i as post fix?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Personally I tried to avoid using call execute statement, it looks cumbersome to me, especially when code gets bigger and intertwined with other logic.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 16:46:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216983#M2258</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2015-05-19T16:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: set IML matrix name based on the do loop, how do I do that?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216984#M2259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you really want to go down this route, see this&lt;A class="active_link" href="http://blogs.sas.com/content/iml/2011/03/23/indirect-assignment-how-to-create-and-use-matrices-named-x1-x2-xn.html"&gt; article on indirect assignment&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, actually requiring this feature is very rare.&amp;nbsp; Why don't you share what you are trying to accomplish? There is probably a simpler approach.&amp;nbsp; For your example, the conventional approach would be to form the vector&lt;/P&gt;&lt;P&gt;y = {5,5,5};&lt;/P&gt;&lt;P&gt;so that y[1] = y[2] = y[3] = 5.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 17:24:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216984#M2259</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-05-19T17:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: set IML matrix name based on the do loop, how do I do that?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216985#M2260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;assigning the matrix to the same matrix name in a loop is very inconvenient, especially in debug stage.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For instance, in the 3 loops, 2nd looping has some calculation needs special treatment, but the matrix name is the same, how am I supposed to manipuate the 2nd matrix? It is very cumbersome to do matrix manipulation without the valid reference.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 00:30:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216985#M2260</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2015-05-20T00:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: set IML matrix name based on the do loop, how do I do that?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216986#M2261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can access and manipulate each matrix independently. Rick's point is that doing everything indirectly is going to look ugly, as I imagine the actual problem you are trying to solve is a lot more complicated than the three 5s, and you will end up with a program full of VALSET and VALUE which will be difficult for others to understand.&amp;nbsp; For example:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp; /* create an 'array' of 3 identity matrices of varying size */&lt;BR /&gt;&amp;nbsp; y = 'y_1' : 'y_3';&lt;BR /&gt;&amp;nbsp; do k = 1 to 3;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call valset( y&lt;K&gt; , i(k) );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print (value(y&lt;K&gt;));&lt;BR /&gt;&amp;nbsp; end;&lt;/K&gt;&lt;/K&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* scale each identity matrix in the array by its side,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for the 2nd matrix also add 5 to all elements */&lt;BR /&gt;&amp;nbsp; do k = 1 to 3;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call valset( y&lt;K&gt;, value(y&lt;K&gt;) # k );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if k = 2 then call valset (y&lt;K&gt;, value(y&lt;K&gt;) + 5 );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print (value(y&lt;K&gt;));&lt;BR /&gt;&amp;nbsp; end;&lt;/K&gt;&lt;/K&gt;&lt;/K&gt;&lt;/K&gt;&lt;/K&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 07:52:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216986#M2261</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2015-05-20T07:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: set IML matrix name based on the do loop, how do I do that?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216987#M2262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd like to help. If you tell us what you are trying to accomplish, it would be easier.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 10:38:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/set-IML-matrix-name-based-on-the-do-loop-how-do-I-do-that/m-p/216987#M2262</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-05-20T10:38:17Z</dc:date>
    </item>
  </channel>
</rss>

