<?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 Calling a macro function within a macro function in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-a-macro-function-within-a-macro-function/m-p/825947#M41185</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have got some problems to call macro functions within macro functions.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;For instance, why does that little program returns the following error :&amp;nbsp;ERROR: A character operand was found in the %EVAL function where a numeric operand is required. The condition was: 20+ 50;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro one(A,B);
     %sysevalf(&amp;amp;A-&amp;amp;B);
%mend one;

%macro two(C);
     %sysevalf(&amp;amp;C. + %one(100,50));
%mend two;

%two(20);&lt;/PRE&gt;&lt;P&gt;I mean, why is there a ";" after my numeric value? Besides, is there a keyword to return the value of a macro program?&lt;/P&gt;&lt;P&gt;Also, I read that macro function aren't really made for coding in SAS so how do we code in SAS Enterprise Guide?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for all your help in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jul 2022 14:55:23 GMT</pubDate>
    <dc:creator>jon8</dc:creator>
    <dc:date>2022-07-28T14:55:23Z</dc:date>
    <item>
      <title>Calling a macro function within a macro function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-a-macro-function-within-a-macro-function/m-p/825947#M41185</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have got some problems to call macro functions within macro functions.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;For instance, why does that little program returns the following error :&amp;nbsp;ERROR: A character operand was found in the %EVAL function where a numeric operand is required. The condition was: 20+ 50;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro one(A,B);
     %sysevalf(&amp;amp;A-&amp;amp;B);
%mend one;

%macro two(C);
     %sysevalf(&amp;amp;C. + %one(100,50));
%mend two;

%two(20);&lt;/PRE&gt;&lt;P&gt;I mean, why is there a ";" after my numeric value? Besides, is there a keyword to return the value of a macro program?&lt;/P&gt;&lt;P&gt;Also, I read that macro function aren't really made for coding in SAS so how do we code in SAS Enterprise Guide?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for all your help in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 14:55:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-a-macro-function-within-a-macro-function/m-p/825947#M41185</guid>
      <dc:creator>jon8</dc:creator>
      <dc:date>2022-07-28T14:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a macro function within a macro function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-a-macro-function-within-a-macro-function/m-p/825958#M41188</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/429631"&gt;@jon8&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/429631"&gt;@jon8&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;why is there a ";" after my numeric value?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It's the semicolon you put (inappropriately) after the %SYSEVALF function call. Just remove it in both cases. Function-style macros typically resolve to a "pure" value and you don't want that to be followed by a semicolon as this would be incorrect syntax in most applications of the macro. Also, to test macro TWO I would use a %PUT statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put %two(20);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 15:25:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-a-macro-function-within-a-macro-function/m-p/825958#M41188</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-07-28T15:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a macro function within a macro function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-a-macro-function-within-a-macro-function/m-p/825962#M41189</link>
      <description>&lt;P&gt;There is a semi-colon because the macro you called generated a semi-colon.&amp;nbsp; If you want to write a macro that can be use like a "function" then make sure it only generates text that can become part of an expression.&amp;nbsp; So no statements. And definitely no steps.&amp;nbsp; The macro language is a text pre-processor, nothing more. So any text the macro emits gets consumed by the down stream user of the text it produces.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro one(A,B);
   %sysevalf(&amp;amp;A-&amp;amp;B)
%mend one;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't really program in Enterprise Guide.&amp;nbsp; Enterprise Guide is GUI tool to allow you to run SAS code.&amp;nbsp; &amp;nbsp;It has widgets that help you generate SAS code.&amp;nbsp;You can make process flows to setup the order you want things to happen.&amp;nbsp; But it is not a programming language.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 15:34:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-a-macro-function-within-a-macro-function/m-p/825962#M41189</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-28T15:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a macro function within a macro function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-a-macro-function-within-a-macro-function/m-p/825965#M41190</link>
      <description>&lt;P&gt;Try running this example:&lt;/P&gt;
&lt;PRE&gt;%macro one(A,B);
     %sysevalf(&amp;amp;A-&amp;amp;B)
%mend one;

%macro two(C);
     %sysevalf(&amp;amp;C. + %one(100,50))
%mend two;

%put the value is: %two(20);&lt;/PRE&gt;
&lt;P&gt;You placed a ; in two places it was not desirable if you want to use this way.&lt;/P&gt;
&lt;P&gt;In many cases that extra ; would be null statement but in the resolution of %one it becomes part of the returned value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to expose a resolved value the general structure of this sort of macro is&lt;/P&gt;
&lt;PRE&gt;%macro dummy(&amp;lt;parameter list&amp;gt;)
&amp;lt;various logic that uses macro functions only to combine
or calculate assigning a single "value" &amp;gt;
value
%mend
&lt;/PRE&gt;
&lt;P&gt;Value, which would likely be macro variable reference such as &amp;amp;theresult , without a semicolon is the value seen by code that calls the function. For this reason it is a good idea to provide a default result 0 or similar for when the parameter list is empty or cannot complete constructing the actual desired result for some reason.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure where this comes from: "Also, I read that macro function aren't really made for coding in SAS so how do we code in SAS Enterprise Guide?".&amp;nbsp; There may be some bits involved with Enterprise Guide related to the interface but macro functions are part of SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 15:36:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-a-macro-function-within-a-macro-function/m-p/825965#M41190</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-28T15:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a macro function within a macro function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-a-macro-function-within-a-macro-function/m-p/825974#M41191</link>
      <description>Thank you very much for much. It really helped me figure out a lot of problems in my macros statements!!&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Jul 2022 15:49:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-a-macro-function-within-a-macro-function/m-p/825974#M41191</guid>
      <dc:creator>jon8</dc:creator>
      <dc:date>2022-07-28T15:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a macro function within a macro function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-a-macro-function-within-a-macro-function/m-p/825975#M41192</link>
      <description>Ok Thank you so much for your help! Have a Nice day !&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Jul 2022 15:49:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-a-macro-function-within-a-macro-function/m-p/825975#M41192</guid>
      <dc:creator>jon8</dc:creator>
      <dc:date>2022-07-28T15:49:47Z</dc:date>
    </item>
  </channel>
</rss>

