<?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: The matrix in the modules in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/The-matrix-in-the-modules/m-p/393446#M3722</link>
    <description>&lt;P&gt;thanks for your code, it does work. And one more question, in some loop "t", there is no data read into SS (the reason here is that no COL2 equal to g=D[t,1] in the (dsname)). SS will keep the value of the previous matrix in "t-1" or be reset to invalid value or something else?&lt;/P&gt;</description>
    <pubDate>Wed, 06 Sep 2017 07:24:29 GMT</pubDate>
    <dc:creator>supmilk</dc:creator>
    <dc:date>2017-09-06T07:24:29Z</dc:date>
    <item>
      <title>The matrix in the modules</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/The-matrix-in-the-modules/m-p/393339#M3719</link>
      <description>&lt;P&gt;hey guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I put a matrix as an arguement in the start finish module, but it seems to exist some problem, that some loops work but some not. Can I set a matrix as an arguement in the start-finish module?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro calculate();

%do i=1 %to 2320;

%let e=%sysfunc(cat(&amp;amp;i));
%let first="spl1.split";
%let name="";

data _null_;
b=&amp;amp;e;
a=&amp;amp;first;
x=strip(a)||strip(b);
call symput("name",x);
run;
%put &amp;amp;name;

proc iml;
load D;
load LL;

  start LLH(st,fi,S);
  b_1=(S[st:(fi-1),4]`)*S[(st+1):fi,4]/((S[st:(fi-1),4]`)*S[st:(fi-1),4]);
  b_2s=S[(st+1):fi,4]-b_1*S[st:(fi-1),4];
  b_2=b_2s[:];
  sigma_s1=S[(st+1):fi,4]-b_1*S[st:(fi-1),4]-b_2;
  sigma_s2=sigma_s1##J((fi-st),1,2);
  sigma=(fi-st-1)/(fi-st-2)*sigma_s2[:];
  LLF=(-0.5*(fi-st-1))*log(2*arcos(-1)*(sigma))-1/(2*sigma)*((S[st:(fi-1),4]`)*S[st:(fi-1),4]);
  return(LLF);
  finish LLH;

use &amp;amp;name;
  %do t=1 %to 120;
  g=D[&amp;amp;t,1];
  read all where(COL2=g) into SS; 
  LL[&amp;amp;i,&amp;amp;t]=LLH(1,15,SS);
  %end;
store LL;
quit;
%end;
%mend;

%calculate();&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 18:44:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/The-matrix-in-the-modules/m-p/393339#M3719</guid>
      <dc:creator>supmilk</dc:creator>
      <dc:date>2017-09-05T18:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: The matrix in the modules</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/The-matrix-in-the-modules/m-p/393341#M3720</link>
      <description>&lt;P&gt;Yes, you can&amp;nbsp;&lt;SPAN&gt;set a matrix as an argument in a&amp;nbsp;module.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I&amp;nbsp;don't think there is a reason to use this macro loop. &amp;nbsp;Just use the standard SAS/IML loops to&amp;nbsp;read the many data sets. For example, see the article&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2013/07/29/read-data-sets-array-names.html" target="_self"&gt;"Read data sets that are specified by an array of names"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your &amp;nbsp;program would look like this (untested):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
/* load matrices and define modules HERE */

fname = "split1":"split2320";
do i = 1 to ncol(fname);
   dsname = "spl1." + strip(fname[i]);
   use (dsname);
      do t=1 to 120;
         g=D[t,1];
         read all where(COL2=g) into SS; 
         LL[i,t]=LLH(1,15,SS);
      end;
   close;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 18:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/The-matrix-in-the-modules/m-p/393341#M3720</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-09-05T18:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: The matrix in the modules</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/The-matrix-in-the-modules/m-p/393446#M3722</link>
      <description>&lt;P&gt;thanks for your code, it does work. And one more question, in some loop "t", there is no data read into SS (the reason here is that no COL2 equal to g=D[t,1] in the (dsname)). SS will keep the value of the previous matrix in "t-1" or be reset to invalid value or something else?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 07:24:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/The-matrix-in-the-modules/m-p/393446#M3722</guid>
      <dc:creator>supmilk</dc:creator>
      <dc:date>2017-09-06T07:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: The matrix in the modules</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/The-matrix-in-the-modules/m-p/393452#M3723</link>
      <description>&lt;P&gt;When there is no data to read, I think&amp;nbsp;you will get a warning message in the log file and the matrix SS will be undefined.&amp;nbsp; This will most likely create problems later on, so you need to test for the empty matrix.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if nrow(SS) = 0
   then print 'No data found!';
   else do;
     &amp;lt; do stuff with SS&amp;gt;
   end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Sep 2017 08:23:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/The-matrix-in-the-modules/m-p/393452#M3723</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2017-09-06T08:23:25Z</dc:date>
    </item>
  </channel>
</rss>

