<?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 print out red colored error message inside a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-print-out-red-colored-error-message-inside-a-macro/m-p/932471#M366824</link>
    <description>&lt;P&gt;Why are you using %IF to evaluate DATA variables?&lt;/P&gt;
&lt;P&gt;The text X=3 to the macro processor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro T;
DATA T;
  X = 3;
  IF X = 3 THEN PUT "ERROR: this should not happen ";
RUN;
%mend;

%T;&lt;/PRE&gt;
&lt;P&gt;If you want to compare the value of a MACRO variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let x=3;
%if &amp;amp;x. = 3 %then %do;
   %put ERROR: This is an error message;
%end;&lt;/PRE&gt;</description>
    <pubDate>Fri, 14 Jun 2024 19:18:25 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-06-14T19:18:25Z</dc:date>
    <item>
      <title>How to print out red colored error message inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-print-out-red-colored-error-message-inside-a-macro/m-p/932463#M366818</link>
      <description>&lt;P&gt;I am trying to print out an error message (with the red color) in the log if certain conditions are met inside a macro.&lt;/P&gt;&lt;P&gt;The first data step outside of a macro worked as intended, I am able to see the red color error message in the log.&lt;/P&gt;&lt;P&gt;However, I want to achieve the same within the macro, but putlog or %putlog does not work inside the macro, and %put does not print out the error message in the same way as the first data step did.&lt;/P&gt;&lt;P&gt;Can anyone share some insights on how to achieve this? Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;DATA T;
X = 3;
IF X = 3 THEN putlog "ERROR: this should not happen";
RUN;

%macro T;
DATA T;
X = 3;
%IF X = 3 %THEN %PUT "ERROR: this should not happen ";
RUN;
%mend;
%T;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Jun 2024 18:58:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-print-out-red-colored-error-message-inside-a-macro/m-p/932463#M366818</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2024-06-14T18:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to print out red colored error message inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-print-out-red-colored-error-message-inside-a-macro/m-p/932467#M366822</link>
      <description>&lt;P&gt;Have you tried getting rid of the quotes with %PUT?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2024 19:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-print-out-red-colored-error-message-inside-a-macro/m-p/932467#M366822</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2024-06-14T19:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to print out red colored error message inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-print-out-red-colored-error-message-inside-a-macro/m-p/932471#M366824</link>
      <description>&lt;P&gt;Why are you using %IF to evaluate DATA variables?&lt;/P&gt;
&lt;P&gt;The text X=3 to the macro processor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro T;
DATA T;
  X = 3;
  IF X = 3 THEN PUT "ERROR: this should not happen ";
RUN;
%mend;

%T;&lt;/PRE&gt;
&lt;P&gt;If you want to compare the value of a MACRO variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let x=3;
%if &amp;amp;x. = 3 %then %do;
   %put ERROR: This is an error message;
%end;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Jun 2024 19:18:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-print-out-red-colored-error-message-inside-a-macro/m-p/932471#M366824</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-06-14T19:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to print out red colored error message inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-print-out-red-colored-error-message-inside-a-macro/m-p/932474#M366826</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;That's great. I know what the issue is - 1)I shouldn't have use quoted to wrap the error message inside the macro. 2)Also, I am not aware we can use %if %then %else outside of a macro, so this is a great discovery for me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lastly, I used %if to evaluate data variable is because I used a bad example to ask this question and I realized it's a bad demonstration.&lt;/P&gt;&lt;P&gt;Thanks for your solution, that's amazing great!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2024 19:31:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-print-out-red-colored-error-message-inside-a-macro/m-p/932474#M366826</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2024-06-14T19:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to print out red colored error message inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-print-out-red-colored-error-message-inside-a-macro/m-p/932475#M366827</link>
      <description>&lt;P&gt;Yes, I realized it didn't work because I had quote around the text. Thanks for the tips!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2024 19:32:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-print-out-red-colored-error-message-inside-a-macro/m-p/932475#M366827</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2024-06-14T19:32:57Z</dc:date>
    </item>
  </channel>
</rss>

