<?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: Loop over names with a suffix in Sas in proc iml in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Loop-over-names-with-a-suffix-in-Sas-in-proc-iml/m-p/253146#M2595</link>
    <description>&lt;P&gt;Have a&amp;nbsp;look at CALL EXECUTE as you can use this to run IML statements that you have created in a character variable.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i = 1 to 10;
  call execute( 'imlData' + strip(char(i)) + '[1,1] = 2#i;' );
end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This should do what you want, but the problem is that a real program with a lot of CALL EXECUTEs can be difficult to read and to maintain, so you might be better off keeping all your data in one large matrix and then access individual matrices by subsetting rows and columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that you must use CALL EXECUTE inside an IML&amp;nbsp;module.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Feb 2016 10:41:27 GMT</pubDate>
    <dc:creator>IanWakeling</dc:creator>
    <dc:date>2016-02-29T10:41:27Z</dc:date>
    <item>
      <title>Loop over names with a suffix in Sas in proc iml</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Loop-over-names-with-a-suffix-in-Sas-in-proc-iml/m-p/253142#M2594</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Hello all,&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;I have 10 datasets going from input1 to input10. Then I want to transform them to iml data so I can do complex matrix calculations. The problem is that I can loop over the datasets with &amp;amp;i. as the variable suffix part. But I do not know how to loop over them when they are iml data, is it possible to do this in iml or is it just not possible?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080"&gt;iml&lt;/FONT&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;&lt;FONT color="#000080"&gt;&lt;FONT color="#000080"&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;%MACRO&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;I&gt;DO_BRANCH&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;%do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; i=1 &lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;%to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; 10;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;use input&amp;amp;&lt;FONT color="#008080"&gt;&lt;FONT color="#008080"&gt;&lt;FONT color="#008080"&gt;i.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;read all var _ALL_ into imlData&amp;amp;&lt;FONT color="#008080"&gt;&lt;FONT color="#008080"&gt;&lt;FONT color="#008080"&gt;i.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;[colname=varNames]; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;close input&amp;amp;&lt;FONT color="#008080"&gt;&lt;FONT color="#008080"&gt;&lt;FONT color="#008080"&gt;i.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;&lt;FONT color="#000080"&gt;&lt;FONT color="#000080"&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;%MEND&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; DO_BRANCH;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;%&lt;STRONG&gt;&lt;I&gt;DO_BRANCH&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;%The code below does not work !!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt; i =&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;10&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;imlData&amp;amp;i.[1,1] = assign a new complex value (not important);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Courier New"&gt;If anybody knows the answer please tell me :), thank you all!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Feb 2016 09:46:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Loop-over-names-with-a-suffix-in-Sas-in-proc-iml/m-p/253142#M2594</guid>
      <dc:creator>TheAzerty</dc:creator>
      <dc:date>2016-02-29T09:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: Loop over names with a suffix in Sas in proc iml</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Loop-over-names-with-a-suffix-in-Sas-in-proc-iml/m-p/253146#M2595</link>
      <description>&lt;P&gt;Have a&amp;nbsp;look at CALL EXECUTE as you can use this to run IML statements that you have created in a character variable.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i = 1 to 10;
  call execute( 'imlData' + strip(char(i)) + '[1,1] = 2#i;' );
end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This should do what you want, but the problem is that a real program with a lot of CALL EXECUTEs can be difficult to read and to maintain, so you might be better off keeping all your data in one large matrix and then access individual matrices by subsetting rows and columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that you must use CALL EXECUTE inside an IML&amp;nbsp;module.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Feb 2016 10:41:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Loop-over-names-with-a-suffix-in-Sas-in-proc-iml/m-p/253146#M2595</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2016-02-29T10:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: Loop over names with a suffix in Sas in proc iml</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Loop-over-names-with-a-suffix-in-Sas-in-proc-iml/m-p/253162#M2596</link>
      <description>&lt;P&gt;The answer depends on what you want to do with the data.&lt;/P&gt;
&lt;P&gt;1. Do you want to analyze each data set separately? (This is the most common wish.) Then you can &lt;A href="http://blogs.sas.com/content/iml/2013/07/29/read-data-sets-array-names.html" target="_self"&gt;read the data set names from an array &lt;/A&gt;like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
dsName = "input1":"input10";
do i = 1 to ncol(dsName);
   use (dsName[i]);
   read all var _ALL_ into X;
   close (dsName[i]);
   /* do a computation for this data set */
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Do you want to read all of the data into IML matrices and then do computations across data sets? (This is rare.) If so, you can follow the directions in this article about &lt;A href="http://blogs.sas.com/content/iml/2013/07/31/read-100-data-sets-into-matrices.html" target="_self"&gt;reading data into separate matrices.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In either case, you don't need any macro code, so get rid of the %DO statements and replace them with SAS/IML DO loops.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Feb 2016 12:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Loop-over-names-with-a-suffix-in-Sas-in-proc-iml/m-p/253162#M2596</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-02-29T12:43:37Z</dc:date>
    </item>
  </channel>
</rss>

