<?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: Understanding %sysfunc in open code with an example in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Understanding-sysfunc-in-open-code-with-an-example/m-p/486954#M287247</link>
    <description>&lt;P&gt;Hi RW9,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes I try find the path part of the name. I can deduce from your answer that I would then need for each function a %sysfunc...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let test=a/b/c.sas;
%let ysys=%sysfunc(substr(&amp;amp;test.,1,%sysfunc(length(%sysfunc(scan(&amp;amp;test.,-1,/))))));
%put &amp;amp;ysys;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It is then providing me with a correct result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Agreed, that there are easier and more elegant solution, but wanted to understand the use of %sysfunc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;saskap&lt;/P&gt;</description>
    <pubDate>Wed, 15 Aug 2018 11:20:45 GMT</pubDate>
    <dc:creator>saskapa</dc:creator>
    <dc:date>2018-08-15T11:20:45Z</dc:date>
    <item>
      <title>Understanding %sysfunc in open code with an example</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Understanding-sysfunc-in-open-code-with-an-example/m-p/486941#M287245</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have wrote a code to illustrate the use of %sysfunc in a open code. The first code is not using %sysfunc, instead I use macro functions :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  %let test=a/b/c.sas;
  %let nsys=%substr ( &amp;amp;test,1,%length (%scan ( &amp;amp;test,-1,/) ) );
  %put &amp;amp;nsys;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now I would like to use the same logic but this time I will use %sysfunc with sas function ( not macro function)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  %let test=a/b/c.sas;
  %let ysys=%sysfunc ( substr ( &amp;amp;test,1,length (scan ( &amp;amp;test,-1,/) ) ) );
  %put &amp;amp;ysys;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I get an error :&lt;BR /&gt;&lt;BR /&gt;ERROR: Argument 3 to function SUBSTR referenced by the %SYSFUNC or %QSYSFUNC macro function is&lt;BR /&gt; not a number.&lt;BR /&gt;ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list.&lt;BR /&gt; Execution of %SYSCALL statement or %SYSFUNC or %QSYSFUNC function reference is&lt;BR /&gt; terminated.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;It looks like the type of value returned by length() is not numeric. What is the difference between the codes that make my %sysfunc version not working properly ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another question/advice, is it possible to use %sysfunc with a macro function ? example %sysfunc(%scan(&amp;amp;alpha,1)) or should we only use %sysfunc with non macro sas function like&amp;nbsp;&lt;SPAN&gt;%sysfunc(scan(&amp;amp;alpha,1))&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;saskap&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 10:48:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Understanding-sysfunc-in-open-code-with-an-example/m-p/486941#M287245</guid>
      <dc:creator>saskapa</dc:creator>
      <dc:date>2018-08-15T10:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding %sysfunc in open code with an example</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Understanding-sysfunc-in-open-code-with-an-example/m-p/486947#M287246</link>
      <description>&lt;P&gt;Well, first off you need to put another %sysfunc in to call the next function:&lt;/P&gt;
&lt;PRE&gt;%let test=a/b/c.sas;
%let ysys=%sysfunc(substr(&amp;amp;test.,1,%sysfunc(length(scan(&amp;amp;test.,-1,/)))));
%put &amp;amp;ysys;&lt;/PRE&gt;
&lt;P&gt;However that won't work as you think it will, logic isn't right.&amp;nbsp; What is it your actually trying to do.&amp;nbsp; A hint for you, if you find you are using lots of &amp;amp;'s, or %sysfunc or macro, then its likely a simple rethink of your problem will result in simpler easier code.&amp;nbsp; I assume you are trying to find the path part of the name?&amp;nbsp; If so there might be automatic variables available for this, or you can include better code in your actual program to identify this.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 11:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Understanding-sysfunc-in-open-code-with-an-example/m-p/486947#M287246</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-15T11:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding %sysfunc in open code with an example</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Understanding-sysfunc-in-open-code-with-an-example/m-p/486954#M287247</link>
      <description>&lt;P&gt;Hi RW9,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes I try find the path part of the name. I can deduce from your answer that I would then need for each function a %sysfunc...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let test=a/b/c.sas;
%let ysys=%sysfunc(substr(&amp;amp;test.,1,%sysfunc(length(%sysfunc(scan(&amp;amp;test.,-1,/))))));
%put &amp;amp;ysys;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It is then providing me with a correct result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Agreed, that there are easier and more elegant solution, but wanted to understand the use of %sysfunc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;saskap&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 11:20:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Understanding-sysfunc-in-open-code-with-an-example/m-p/486954#M287247</guid>
      <dc:creator>saskapa</dc:creator>
      <dc:date>2018-08-15T11:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding %sysfunc in open code with an example</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Understanding-sysfunc-in-open-code-with-an-example/m-p/486966#M287248</link>
      <description>&lt;P&gt;Whilst I appreciate you marking your own post as the answer to the question, it is not very helpful to other users who are looking for the answer to the question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In terms of %sysfunc(), that runs one SAS function, hence if you have multiple functions then you need several %sysfunc's.&amp;nbsp; The simple answer to:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"but wanted to understand the use of %sysfunc."&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is that there is rarely, if ever a need to use it.&amp;nbsp; Proper well thought out code does not need the use of any macro code.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 12:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Understanding-sysfunc-in-open-code-with-an-example/m-p/486966#M287248</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-15T12:29:50Z</dc:date>
    </item>
  </channel>
</rss>

