<?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 Assign Matrix Name via DO Loop Function in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Assign-Matrix-Name-via-DO-Loop-Function/m-p/51173#M304</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi! It's me again....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While working with the DO loop function I encountered another problem;) I'd like to create several matrices with the help of the DO loop function but I'm still struggling with the matrices' names. Is it possible to assign a matrix name via the DO loop function as well?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do i=1 to 10;&lt;/P&gt;&lt;P&gt;Matrix_i=.....&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 20 Nov 2011 20:32:59 GMT</pubDate>
    <dc:creator>MarkGIP</dc:creator>
    <dc:date>2011-11-20T20:32:59Z</dc:date>
    <item>
      <title>Assign Matrix Name via DO Loop Function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Assign-Matrix-Name-via-DO-Loop-Function/m-p/51173#M304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi! It's me again....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While working with the DO loop function I encountered another problem;) I'd like to create several matrices with the help of the DO loop function but I'm still struggling with the matrices' names. Is it possible to assign a matrix name via the DO loop function as well?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do i=1 to 10;&lt;/P&gt;&lt;P&gt;Matrix_i=.....&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Nov 2011 20:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Assign-Matrix-Name-via-DO-Loop-Function/m-p/51173#M304</guid>
      <dc:creator>MarkGIP</dc:creator>
      <dc:date>2011-11-20T20:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Assign Matrix Name via DO Loop Function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Assign-Matrix-Name-via-DO-Loop-Function/m-p/51174#M305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh... nevermind. I just discovered the &lt;A href="http://blogs.sas.com/iml/index.php?/archives/105-Indirect-Assignment-How-to-Create-and-Use-Matrices-Named-x1,-x2,...,-xn.html"&gt;article&lt;/A&gt; of Rick on this topic..... Thank you Rick;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But maybe somebody knows how to address a specific matrix with the DO Loop Function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the functions are as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;m1=x1&lt;/P&gt;&lt;P&gt;m2=x2-x1&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;m10=x10-x9&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Nov 2011 21:25:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Assign-Matrix-Name-via-DO-Loop-Function/m-p/51174#M305</guid>
      <dc:creator>MarkGIP</dc:creator>
      <dc:date>2011-11-20T21:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: Assign Matrix Name via DO Loop Function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Assign-Matrix-Name-via-DO-Loop-Function/m-p/51175#M306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; It is very rare that you need to have matrices of different names (as I explain in &lt;A href="http://blogs.sas.com/iml/index.php?/archives/101-The-Macro-Loop-That-Vanished-How-to-Simplify-Your-SASIML-Programs.html"&gt;the article prior to the one you reference&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;Sometimes people THINK they need to do this because they are trying to wrap SAS/IML statements within a macro loop, which is rarely necessary. Instead, you can use the SAS/IML language itself&amp;nbsp; to perform whatever the macro loop is doing. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You didn't post an example, but one common programming technique is to have all of the x vars in an nx10 matrix, where each column is a variable.&lt;/P&gt;&lt;P&gt;Then the following statements form a matrix m where each column is what you want:&lt;/P&gt;&lt;P&gt;y = j(n,1,0) || x; /* temp: append column of zeros */&lt;/P&gt;&lt;P&gt;m = y[,2:11] - y[,1:10];&lt;/P&gt;&lt;P&gt;free y;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another alternative, if you don't need the whole matrix, is to loop:&lt;/P&gt;&lt;P&gt;do i = 1 to 10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if i = 1 then m=x[,i];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else m = x[,i] - x[,i-1];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; /* do something with m, which is m_i in your notation */&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Nov 2011 14:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Assign-Matrix-Name-via-DO-Loop-Function/m-p/51175#M306</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2011-11-21T14:58:10Z</dc:date>
    </item>
  </channel>
</rss>

