<?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: SAS Advanced Exam in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/SAS-Advanced-Exam/m-p/460678#M24056</link>
    <description>Thank you much !&lt;BR /&gt;</description>
    <pubDate>Tue, 08 May 2018 13:02:41 GMT</pubDate>
    <dc:creator>Alass006</dc:creator>
    <dc:date>2018-05-08T13:02:41Z</dc:date>
    <item>
      <title>SAS Advanced Exam</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/SAS-Advanced-Exam/m-p/460510#M24048</link>
      <description>&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am reaching out for sas question and wondering if you can assist me in explaining the right anwer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following SAS program is submitted:&lt;/P&gt;&lt;P&gt;%macro mysum(n);&lt;/P&gt;&lt;P&gt;%if &amp;amp;n &amp;gt; 1 %then %eval(&amp;amp;n + %mysum(%eval(&amp;amp;n-1)));&lt;/P&gt;&lt;P&gt;%else &amp;amp;n;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%put %mysum(4);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which output is written to the log?&lt;/P&gt;&lt;P&gt;A. 10&lt;/P&gt;&lt;P&gt;B. 4+3+2+1&lt;/P&gt;&lt;P&gt;C. 7&lt;/P&gt;&lt;P&gt;D. A character operand was found in the %EVAL function or %IF condition where a numeric operand is required.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;correct_answer = "A"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would go for "C."&amp;nbsp; I have access to enterprise guide but nothing is written to the&amp;nbsp;&amp;nbsp;log.&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 17:00:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/SAS-Advanced-Exam/m-p/460510#M24048</guid>
      <dc:creator>Alass006</dc:creator>
      <dc:date>2018-05-07T17:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Advanced Exam</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/SAS-Advanced-Exam/m-p/460529#M24050</link>
      <description>&lt;P&gt;I think you are getting 7 because you are not following the recursion all the way through.&amp;nbsp; Notice that in the %if statement that %mysum is called again, except with &amp;amp;n -1. Think about what %mysum(3) returns.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, unless you have settings to prevent %put from outputting to the log, I think the answer is getting buried&amp;nbsp;in the line execution numbers.&amp;nbsp; This is what mine looks like after being ran:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;1 %_eg_hidenotesandsource;&lt;BR /&gt;5 %_eg_hidenotesandsource;&lt;BR /&gt;31&lt;BR /&gt;32 %macro mysum(n);&lt;BR /&gt;33&lt;BR /&gt;34 %if &amp;amp;n &amp;gt; 1 %then %eval(&amp;amp;n + %mysum(%eval(&amp;amp;n-1)));&lt;BR /&gt;35&lt;BR /&gt;36 %else &amp;amp;n;&lt;BR /&gt;37&lt;BR /&gt;38 %mend;&lt;BR /&gt;39&lt;BR /&gt;40 %put %mysum(4);&lt;BR /&gt;10&lt;BR /&gt;41&lt;BR /&gt;42 %_eg_hidenotesandsource;&lt;BR /&gt;57&lt;BR /&gt;58&lt;BR /&gt;59 %_eg_hidenotesandsource;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Notice that 10 is in there right between line 40 and 41.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something that I do when I am debugging my macros is to add log notes when the macro is called.&amp;nbsp; For example:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro mysum(n);

%put mysum called: n=&amp;amp;n;

%if &amp;amp;n &amp;gt; 1 %then %eval(&amp;amp;n + %mysum(%eval(&amp;amp;n-1)));

%else &amp;amp;n;

%mend;

%put %mysum(4);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;you can then see it being called 4 total times in the log:&amp;nbsp;&lt;/P&gt;&lt;P&gt;42 %put %mysum(4);&lt;BR /&gt;mysum called: n=4&lt;BR /&gt;mysum called: n=3&lt;BR /&gt;mysum called: n=2&lt;BR /&gt;mysum called: n=1&lt;BR /&gt;10&lt;/P&gt;&lt;P&gt;43&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 17:45:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/SAS-Advanced-Exam/m-p/460529#M24050</guid>
      <dc:creator>Urban_Science</dc:creator>
      <dc:date>2018-05-07T17:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Advanced Exam</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/SAS-Advanced-Exam/m-p/460548#M24051</link>
      <description>&lt;P&gt;I don't use EG but you might try changing the final %put to this:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="SAS Monospace" size="2"&gt;%put NOTE: Final value of mysum macro is: %mysum(4);
&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;so the result stands out more. If the log uses different appearance for NOTE: WARNING: and ERROR: entries it is likely the result will have those appearance options.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 18:30:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/SAS-Advanced-Exam/m-p/460548#M24051</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-07T18:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Advanced Exam</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/SAS-Advanced-Exam/m-p/460678#M24056</link>
      <description>Thank you much !&lt;BR /&gt;</description>
      <pubDate>Tue, 08 May 2018 13:02:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/SAS-Advanced-Exam/m-p/460678#M24056</guid>
      <dc:creator>Alass006</dc:creator>
      <dc:date>2018-05-08T13:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Advanced Exam</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/SAS-Advanced-Exam/m-p/488024#M25322</link>
      <description>&lt;P&gt;WHEN IS IT GOOD TO COMBINE MULTIPLE SAS DATASETS BY MATCHING KEY VALUES??&lt;/P&gt;&lt;P&gt;WITH INDEXES ON KEY VALUES OR WITHOUT INDEXES ON KEY VALUES&lt;/P&gt;</description>
      <pubDate>Sat, 18 Aug 2018 20:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/SAS-Advanced-Exam/m-p/488024#M25322</guid>
      <dc:creator>raawan</dc:creator>
      <dc:date>2018-08-18T20:26:44Z</dc:date>
    </item>
  </channel>
</rss>

