<?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: Using Data Set Inside Do Loops in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Data-Set-Inside-Do-Loops/m-p/419898#M3901</link>
    <description>&lt;P&gt;Yeah. I know what Rick mean. So here is the code revisited.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DataSet;
	call streaminit(1);
	do Set=1 to 3;
		do Number=1 to 10;
			Variable=rand("normal");
			output;
		end;
	end;
run;

proc iml;
use dataset;

read all var{set};
level=unique(set);
do i=1 to ncol(level);
  read all var _all_ into x where (set=(level[i]));
  print x;
end;

close;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 10 Dec 2017 09:56:23 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-12-10T09:56:23Z</dc:date>
    <item>
      <title>Using Data Set Inside Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Data-Set-Inside-Do-Loops/m-p/419773#M3896</link>
      <description>&lt;P&gt;Hi, I want to ask if this is possible.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DataSet;
	call streaminit(1);
	do Set=1 to 3;
		do Number=1 to 10;
			Variable=rand("normal");
			output;
		end;
	end;
run;

proc iml;
	do IMLSet=1 to 3;
		use DataSet(where=(Set=IMLSet));
			read all var{Variable};
		close DataSet;
	end;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In this case, DataSet contains Variable, which is indexed by both Set and Number. In IML, I intended to load DataSet Set by Set so used a loop with an IML variable IMLSet, but this does not work since the "where" only uses the variables in DataSet and it does not have IMLSet there. Alternatives are welcome.&lt;/P&gt;</description>
      <pubDate>Sat, 09 Dec 2017 06:22:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Data-Set-Inside-Do-Loops/m-p/419773#M3896</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2017-12-09T06:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using Data Set Inside Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Data-Set-Inside-Do-Loops/m-p/419788#M3897</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DataSet;
	call streaminit(1);
	do Set=1 to 3;
		do Number=1 to 10;
			Variable=rand("normal");
			output;
		end;
	end;
run;

proc iml;
use dataset;
read all var{set};
close;
level=unique(set);
do i=1 to ncol(level);
  use dataset;
  read all var _all_ into x where (set=(level[i]));
  print x;
  close;
end;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;P.S. If you really want learn IML code, I really suggest you to read Rick's blog .You can find most answer of IML in it .&lt;/P&gt;</description>
      <pubDate>Sat, 09 Dec 2017 09:46:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Data-Set-Inside-Do-Loops/m-p/419788#M3897</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-12-09T09:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: Using Data Set Inside Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Data-Set-Inside-Do-Loops/m-p/419792#M3900</link>
      <description>&lt;P&gt;KSharp's&amp;nbsp;solution is good. To read more about how to use the WHERE clause with dynamic values that change in a loop. See&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2016/04/04/where-clause-in-sasiml.html" target="_self"&gt;"The WHERE clause in SAS/IML"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only improvement I'd suggest to KSharp's&amp;nbsp;code is to put the USE and CLOSE statements outside the DO loop. There is no need to open/close the data set multiple times. You can apply his solution to the OP's&amp;nbsp;original attempt, as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
use DataSet;
	do IMLSet=1 to 3;
		read all var{Variable} where(Set=(IMLSet));
      print Variable;
	end;
close DataSet;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 Dec 2017 11:21:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Data-Set-Inside-Do-Loops/m-p/419792#M3900</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-12-09T11:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using Data Set Inside Do Loops</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Data-Set-Inside-Do-Loops/m-p/419898#M3901</link>
      <description>&lt;P&gt;Yeah. I know what Rick mean. So here is the code revisited.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DataSet;
	call streaminit(1);
	do Set=1 to 3;
		do Number=1 to 10;
			Variable=rand("normal");
			output;
		end;
	end;
run;

proc iml;
use dataset;

read all var{set};
level=unique(set);
do i=1 to ncol(level);
  read all var _all_ into x where (set=(level[i]));
  print x;
end;

close;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 Dec 2017 09:56:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Data-Set-Inside-Do-Loops/m-p/419898#M3901</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-12-10T09:56:23Z</dc:date>
    </item>
  </channel>
</rss>

