<?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: How to return the number of declared inputs for the function in SAS IML in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-return-the-number-of-declared-inputs-for-the-function-in/m-p/375234#M3599</link>
    <description>&lt;P&gt;I don't think there is a direct analog of 'nargin' in IML, however you could achieve the same effect by giving the input matrix B a blank default value, and then testing the type of matrix B, it will be undefined(U) if the call to the function has not provided a matrix B, or it will be numeric (N) if a value for B is given.&amp;nbsp; The syntax would be along the following lines:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  start mytrace(A, B=);
    if type(B)='U' then return(trace(A)); else etc..;
  finish;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 12 Jul 2017 08:29:41 GMT</pubDate>
    <dc:creator>IanWakeling</dc:creator>
    <dc:date>2017-07-12T08:29:41Z</dc:date>
    <item>
      <title>How to return the number of declared inputs for the function in SAS IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-return-the-number-of-declared-inputs-for-the-function-in/m-p/375230#M3598</link>
      <description>&lt;P&gt;I would like to replicate following Matlab code&amp;nbsp;with SAS IML:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%%% Trace function %%%&lt;BR /&gt;function val = mytrace(A,B)&lt;BR /&gt;if (nargin == 1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; val = sum(diag(A));&lt;BR /&gt;elseif (nargin == 2)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; val = sum(sum(A.*B));&lt;BR /&gt;end&lt;BR /&gt;return&lt;BR /&gt;%%% end of mytrace.m %%%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wondering if there is any similar function in SAS which would return the number of declared inputs for the function&amp;nbsp;just as the&amp;nbsp;nargin(FUN) in matlab?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 08:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-return-the-number-of-declared-inputs-for-the-function-in/m-p/375230#M3598</guid>
      <dc:creator>jazhang</dc:creator>
      <dc:date>2017-07-12T08:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to return the number of declared inputs for the function in SAS IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-return-the-number-of-declared-inputs-for-the-function-in/m-p/375234#M3599</link>
      <description>&lt;P&gt;I don't think there is a direct analog of 'nargin' in IML, however you could achieve the same effect by giving the input matrix B a blank default value, and then testing the type of matrix B, it will be undefined(U) if the call to the function has not provided a matrix B, or it will be numeric (N) if a value for B is given.&amp;nbsp; The syntax would be along the following lines:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  start mytrace(A, B=);
    if type(B)='U' then return(trace(A)); else etc..;
  finish;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jul 2017 08:29:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-return-the-number-of-declared-inputs-for-the-function-in/m-p/375234#M3599</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2017-07-12T08:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to return the number of declared inputs for the function in SAS IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-return-the-number-of-declared-inputs-for-the-function-in/m-p/375251#M3603</link>
      <description>&lt;P&gt;I agree with Ian. &amp;nbsp;You can use default parameter values. If necessary, you can use the ISSKIPPED function in a module to&amp;nbsp;determine if an argument was provided or if the default value is being used. &amp;nbsp;You might enjoy reading the article &lt;A href="http://blogs.sas.com/content/iml/2015/06/17/everything-about-modules.html" target="_self"&gt;"Everything you wanted to know about writing SAS/IML modules,"&lt;/A&gt;&amp;nbsp;which links to additional articles about default parameter values.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 09:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-return-the-number-of-declared-inputs-for-the-function-in/m-p/375251#M3603</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-07-12T09:41:13Z</dc:date>
    </item>
  </channel>
</rss>

