<?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 Macro - Error submitted by using a PUT statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688471#M209150</link>
    <description>No, the program should be that. It can't be CHANGED, that's the meaning.</description>
    <pubDate>Fri, 02 Oct 2020 10:45:27 GMT</pubDate>
    <dc:creator>vittorio_giatti</dc:creator>
    <dc:date>2020-10-02T10:45:27Z</dc:date>
    <item>
      <title>SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688456#M209138</link>
      <description>&lt;P&gt;Hi Everyone.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lately I got to deal with the folliwing issue. I am wondering if there is any SAS inhabitant able to figure a way out of that. It's simple, but not easy.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was the last practical question of the "&lt;FONT size="3"&gt;SAS Certified Professional: Advanced Programming Using SAS 9.4&lt;/FONT&gt;".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Program&lt;/STRONG&gt;:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Test();
  %put ERROR: Do not print;

  proc print data=sashelp.cars;
  run;
%mend;

options /* **??** */;
%Test();&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Log&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dddddddd.JPG" style="width: 274px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50106iF83D8720AF870CF7/image-dimensions/274x144?v=v2" width="274" height="144" role="button" title="dddddddd.JPG" alt="dddddddd.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The description was very clear:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"It's not possible to add anything els&lt;SPAN style="font-family: inherit;"&gt;e to the macro program. &lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;How do we make the program execute without errors?"&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;I am wondering if there is an option (on errors or macro) to avoid it. I already tried a few, but it still makes my brain wrecking.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;Thanks. Regards.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;Vittorio&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 09:53:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688456#M209138</guid>
      <dc:creator>vittorio_giatti</dc:creator>
      <dc:date>2020-10-02T09:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688460#M209140</link>
      <description>&lt;P&gt;I don't see a problem with your code or the results. SAS is doing exactly what the macro says it should do. The fact that the log contains an error statement is because you (or someone) programmed the macro to write&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;ERROR: Do not print&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;to the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, what is the problem?&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 10:02:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688460#M209140</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-10-02T10:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688462#M209142</link>
      <description>The macro program should execute the proc print and not show the error in the log!&lt;BR /&gt;Most likely there is an option for that.&lt;BR /&gt;&lt;BR /&gt;Maybe there is no solution and the question was wrong!</description>
      <pubDate>Fri, 02 Oct 2020 10:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688462#M209142</guid>
      <dc:creator>vittorio_giatti</dc:creator>
      <dc:date>2020-10-02T10:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688464#M209144</link>
      <description>&lt;P&gt;But the macro specifically writes the text "ERROR: Do not print" to the log. That is the first line under %MACRO. That is what the macro was designed to do. If you don't want it to do that, change the macro. You are the programmer, you have complete control over what the macro does.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 10:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688464#M209144</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-10-02T10:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688467#M209146</link>
      <description>&lt;P&gt;That was the exam question. &lt;STRONG&gt;"&lt;/STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;It's not possible to add anything else to the macro program".&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;If I modify the program, the evaluation points are ZERO.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't think you get the question.&lt;/P&gt;&lt;P&gt;Of course you can to modify the code. Here is not possible!!!!!!!!!!!!!!!!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have&amp;nbsp;a&lt;SPAN&gt;&amp;nbsp;sort of constraint that I found myself bumping up against. Again: it's an exam question.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 10:37:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688467#M209146</guid>
      <dc:creator>vittorio_giatti</dc:creator>
      <dc:date>2020-10-02T10:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688469#M209148</link>
      <description>As I said, maybe that was a BUG of the exam. As far as I got from your answers, that's what you also think. Thanks</description>
      <pubDate>Fri, 02 Oct 2020 10:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688469#M209148</guid>
      <dc:creator>vittorio_giatti</dc:creator>
      <dc:date>2020-10-02T10:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688470#M209149</link>
      <description>&lt;P&gt;So we find ourselves in an absurd situation where the code doesn't do what we want, but we are not allowed to change the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, when you say&amp;nbsp;"It's not possible to add anything else to the macro program", I point out that the solution I am proposing, to remove the line of code that we don't want, does not ADD anything else to the macro program. It SUBTRACTS code from the program. Seems to me that is okay according to the directive: "It's not possible to add anything else to the macro program".&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 10:43:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688470#M209149</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-10-02T10:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688471#M209150</link>
      <description>No, the program should be that. It can't be CHANGED, that's the meaning.</description>
      <pubDate>Fri, 02 Oct 2020 10:45:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688471#M209150</guid>
      <dc:creator>vittorio_giatti</dc:creator>
      <dc:date>2020-10-02T10:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688472#M209151</link>
      <description>&lt;P&gt;Then I choose to leave this discussion, as the exam question is absurd, and not worth more of my time. I wish you good luck in finding an answer.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 10:50:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688472#M209151</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-10-02T10:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688481#M209156</link>
      <description>&lt;P&gt;The &lt;STRONG&gt;program&lt;/STRONG&gt; is the entire source code.&amp;nbsp; The &lt;STRONG&gt;macro program&lt;/STRONG&gt; is the section of the macro code that defines the macro Test.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;&lt;SPAN&gt;How do we make the &lt;STRONG&gt;program&lt;/STRONG&gt; execute without errors?&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The &lt;STRONG&gt;program&lt;/STRONG&gt; is already executing correctly as coded without actual errors.&amp;nbsp; The&amp;nbsp;&lt;STRONG&gt;macro program&lt;/STRONG&gt; has been coded to write a message (starting with ERROR:) to the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the inferred task is to change the&amp;nbsp;&lt;STRONG&gt;program&lt;/STRONG&gt; but not the&amp;nbsp;&lt;STRONG&gt;macro program&lt;/STRONG&gt;&amp;nbsp;would you go 'meta' and look at the macro %PUT message ?&amp;nbsp; The message is telling you to DO NOT PRINT.&amp;nbsp; Based on the 'meta' analysis I would say simply comment out the macro invocation.&lt;/P&gt;
&lt;PRE&gt;%*Test();&lt;/PRE&gt;
&lt;P&gt;No error message ! No printing !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;"&lt;SPAN&gt;the exam question is absurd"&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 11:43:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688481#M209156</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-10-02T11:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688488#M209162</link>
      <description>&lt;P&gt;It is not allowed to modify the macro program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Recalling that macro, the result should be:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) no error message&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) proc print (from the sas program) prints&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;None of the exam answer was so dumb: there is an option or the question was wrong (it's not a new).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 11:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688488#M209162</guid>
      <dc:creator>vittorio_giatti</dc:creator>
      <dc:date>2020-10-02T11:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688492#M209166</link>
      <description>*&lt;BR /&gt;2) proc print (from the sas macro program) prints</description>
      <pubDate>Fri, 02 Oct 2020 11:48:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688492#M209166</guid>
      <dc:creator>vittorio_giatti</dc:creator>
      <dc:date>2020-10-02T11:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688495#M209169</link>
      <description>&lt;P&gt;&lt;EM&gt;"It's not possible to add anything els&lt;SPAN&gt;e to the macro program.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;How do we make the program &lt;FONT color="#FF0000"&gt;execute&lt;/FONT&gt; without errors?"&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SAS, highlight this part of the code and then just execute this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  proc print data=sashelp.cars;
  run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thus, we haven't changed the program, every single line of the program still is intact, but we get the desired output.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If that is the correct answer, the person who created this question should be ashamed. And if this answer is correct, this defeats the purpose of having a macro, and it defeats the purpose of programming in general.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 12:08:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688495#M209169</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-10-02T12:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688497#M209171</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I completely agree with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; but i tried to find a solution anyway :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename tf temp;

proc printto log=tf;
run;

%macro Test();
  %put ERROR: Do not print;

  proc print data=sashelp.cars;
  run;
%mend;

proc printto log=log;
run;


data errorless;
infile tf;
input;
retain out 0;

code=prxchange("s/^\d+ //",1,_INFILE_);

if strip(upcase(code))=:'%MACRO' then out=1;
if out and strip(upcase(code)) ne: '%PUT ERROR' then output;
if strip(upcase(code))=:'%MEND' then out=0;
run;

data _NULL_;
set errorless;
call execute(code);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Oct 2020 12:25:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688497#M209171</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2020-10-02T12:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688498#M209172</link>
      <description>&lt;P&gt;I agree with others, it's likely an error in the question (or just a bad question).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unless there is a system option to turn off %PUT statements (I don't think there is), I can't imagine what would be a good answer to this question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since it's apparently a question from a SAS book or online test prep guide, I'd recommend you submit it to the publisher as an erratum.&amp;nbsp; I'd be curious how they respond, please let us know.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 12:29:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688498#M209172</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2020-10-02T12:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro - Error submitted by using a PUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688507#M209176</link>
      <description>&lt;P&gt;This is a solution!! Probably a bit too much for the knowledge the candidate is expected to have, even the functions used are part of the exam, so it might be correct.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The way to h&lt;SPAN&gt;ighlight that part of the code and then execute it only,&amp;nbsp;&lt;/SPAN&gt;can't work in the exam&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; .&lt;/P&gt;&lt;P&gt;That's because in the advanced programming exam, you save a sas program for each answer, and a macro program provided before evaluates your sas program returning a 3-digits code, which has to be insert as answer into a cell. So the whole program is compiled, leaving no possibility to highlight it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 13:23:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-Error-submitted-by-using-a-PUT-statement/m-p/688507#M209176</guid>
      <dc:creator>vittorio_giatti</dc:creator>
      <dc:date>2020-10-02T13:23:35Z</dc:date>
    </item>
  </channel>
</rss>

