<?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 SAS IML: FROOT Function within parameterized module not working in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-FROOT-Function-within-parameterized-module-not-working/m-p/564469#M4692</link>
    <description>&lt;P&gt;Hello everyone, we have a problem when we call the FROOT function within a module. If the module is parameterized, we get an error message. We do not understand why. The following is the example code. Once without parameter transfer in the module (parameters a,b,c are initialized within the module). And once with passing the parameters in the module call.&lt;/P&gt;&lt;P&gt;What is the problem? Obviously a module in which FROOT is called cannot be parameterized.&lt;BR /&gt;How can the problem be solved?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&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;/*Nonlinear solver without error*/
proc iml;

start func(x) global(a,b,c);
measure = (a/x+b/x##2 - c);
return(measure);
finish func;
store module=func;

start getSolution_m;

a = 215;
b = 231.5;
c = 400;

interval = {0.01 2};
roots = froot( "Func", interval);
print roots;
finish;

store module=getSolution_m;
quit;


proc iml;
load;
call getSolution_m;
quit;&lt;/CODE&gt;&lt;/PRE&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;/*Nonlinear solver with error*/
proc iml;

start func(x) global(a,b,c);
measure = (a/x+b/x##2 - c);
return(measure);
finish func;
store module=func;

start getSolution_m(a,b,c);
interval = {0.01 2};
roots = froot( "Func", interval);
print roots;
finish;

store module=getSolution_m;
quit;


proc iml;
load;
call getSolution_m(215,231.5,400);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 07 Jun 2019 13:54:23 GMT</pubDate>
    <dc:creator>AThomalla</dc:creator>
    <dc:date>2019-06-07T13:54:23Z</dc:date>
    <item>
      <title>SAS IML: FROOT Function within parameterized module not working</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-FROOT-Function-within-parameterized-module-not-working/m-p/564469#M4692</link>
      <description>&lt;P&gt;Hello everyone, we have a problem when we call the FROOT function within a module. If the module is parameterized, we get an error message. We do not understand why. The following is the example code. Once without parameter transfer in the module (parameters a,b,c are initialized within the module). And once with passing the parameters in the module call.&lt;/P&gt;&lt;P&gt;What is the problem? Obviously a module in which FROOT is called cannot be parameterized.&lt;BR /&gt;How can the problem be solved?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&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;/*Nonlinear solver without error*/
proc iml;

start func(x) global(a,b,c);
measure = (a/x+b/x##2 - c);
return(measure);
finish func;
store module=func;

start getSolution_m;

a = 215;
b = 231.5;
c = 400;

interval = {0.01 2};
roots = froot( "Func", interval);
print roots;
finish;

store module=getSolution_m;
quit;


proc iml;
load;
call getSolution_m;
quit;&lt;/CODE&gt;&lt;/PRE&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;/*Nonlinear solver with error*/
proc iml;

start func(x) global(a,b,c);
measure = (a/x+b/x##2 - c);
return(measure);
finish func;
store module=func;

start getSolution_m(a,b,c);
interval = {0.01 2};
roots = froot( "Func", interval);
print roots;
finish;

store module=getSolution_m;
quit;


proc iml;
load;
call getSolution_m(215,231.5,400);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Jun 2019 13:54:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-FROOT-Function-within-parameterized-module-not-working/m-p/564469#M4692</guid>
      <dc:creator>AThomalla</dc:creator>
      <dc:date>2019-06-07T13:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML: FROOT Function within parameterized module not working</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-FROOT-Function-within-parameterized-module-not-working/m-p/564479#M4693</link>
      <description>&lt;P&gt;In the second program (which doesn't work), the FUNC module is trying to refer to global symbols a,b, and c, but there are no symbols by that name in the global symbol table. To review how global variables work in SAS/IML, see the article &lt;A href="https://blogs.sas.com/content/iml/2013/04/29/understanding-local-and-global-variables-in-the-sasiml-language.html" target="_self"&gt;"Understanding local and global variables in the SAS/IML language."&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To solve your problem, you can either define (a,b,c) in the main scope of the program, or you can have the GetSolution_m module update the global symbol table by copying its parameters into the global symbols. It sounds like you want the second option. For clarity, the following program uses g_a, g_b, and g_c as the name of the global variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;

start func(x) global(g_a,g_b,g_c);
measure = (g_a/x+g_b/x##2 - g_c);
return(measure);
finish func;
store module=func;

start getSolution_m(a,b,c) global(g_a,g_b,g_c);
g_a = a; g_b = b; g_c = c;  /* copy parameters into the global symbols */
interval = {0.01 2};
roots = froot( "Func", interval);
print roots;
finish;

store module=getSolution_m;
quit;

proc iml;
load;
call getSolution_m(215,231.5,400);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Jun 2019 14:51:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-FROOT-Function-within-parameterized-module-not-working/m-p/564479#M4693</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-06-07T14:51:17Z</dc:date>
    </item>
  </channel>
</rss>

