<?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 let a macro fail and supress the log in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930277#M366001</link>
    <description>&lt;P&gt;Here's some logic lifted from one of my processes that I had to guard against network issues like this. It does not produce a clean log but it does allow the process to continue gracefully. The first trick is to check for the existence of the SYS_PROCHTTP_STATUS_CODE macro before checking for a value.&amp;nbsp; In my case I built in some retry logic, but if it fails again then I fall through and give up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;    %if %symexist(SYS_PROCHTTP_STATUS_CODE) %then
      %do;
        %if &amp;amp;SYS_PROCHTTP_STATUS_CODE. ne 200 or &amp;amp;syserr. ne 0 %then
          %do;
            %put WARNING: Expected 200, but received &amp;amp;SYS_PROCHTTP_STATUS_CODE., SYSERR = &amp;amp;syserr.;
            %put Waiting 20 seconds to retry...;

            %if &amp;amp;SYS_PROCHTTP_STATUS_CODE. eq 403 %then
             %do;
              %put Refreshing auth token;
               %refreshAuthToken; /* special case where I might need to reauth */
             %end;

            data _null_;
              rc=sleep(20,1);
            run;

            /* call macro that retries here */

            %if &amp;amp;SYS_PROCHTTP_STATUS_CODE. ne 200 or &amp;amp;syserr. ne 0 %then
              %do;
                %put WARNING: Failed again. Expected 200, but received &amp;amp;SYS_PROCHTTP_STATUS_CODE., SYSERR = &amp;amp;syserr.;
                %let msgerr = Process stopped after 2 consecutive failures: &amp;amp;SYS_PROCHTTP_STATUS_CODE., see log;
              %end;
          %end;
        %else
          %do;
            %put HTTP result: &amp;amp;SYS_PROCHTTP_STATUS_CODE. &amp;amp;SYS_PROCHTTP_STATUS_PHRASE.;
          %end;

        %if &amp;amp;syserr. = 0 %then
          %do;
		   /* Process Result Here */
          %end;

      %end; /* SYMEXIST SYS_PROCHTTP_STATUS_CODE */
    %else
      %do;
        %put ERROR: PROC HTTP failed! %superq(syserrortext);
        %let msgerr = Errors in fetching data - see log.;
      %end;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 30 May 2024 13:58:24 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2024-05-30T13:58:24Z</dc:date>
    <item>
      <title>How to let a macro fail and supress the log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930262#M365991</link>
      <description>I need to run proc http and sometimes the first request fails, tcpsocketerror.&lt;BR /&gt;&lt;BR /&gt;We couldnt get the problem solved, so i want to create a work a round.&lt;BR /&gt;&lt;BR /&gt;The problem is, i can catch up the "normal" response code with the macro SYS_PROCHTTP_STATUS_CODE and even switch them to a NOTE:, if some bad request/Code 400 happens. But the tcperror cant be suppressed.&lt;BR /&gt;&lt;BR /&gt;I tried NOSOURCE, NONOTES and many other options.&lt;BR /&gt;&lt;BR /&gt;I need something like:&lt;BR /&gt;%macro fail;&lt;BR /&gt;Run without tellin me that you failed;&lt;BR /&gt;&lt;BR /&gt;filename resp TEMP;&lt;BR /&gt;proc http&lt;BR /&gt;method="GET"&lt;BR /&gt;url="&lt;A href="http://httpbin.org/get" target="_blank"&gt;http://httpbin.org/get&lt;/A&gt;"&lt;BR /&gt;out=resp;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;Anybody has something similar? From searching sas/goole i am not sure, if i can even supress the log.</description>
      <pubDate>Thu, 30 May 2024 13:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930262#M365991</guid>
      <dc:creator>VIU</dc:creator>
      <dc:date>2024-05-30T13:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to let a macro fail and supress the log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930265#M365993</link>
      <description>&lt;P&gt;It is not clear what you are asking for.&lt;/P&gt;
&lt;P&gt;Are you asking how to capture the status of an HTTP request and then use that result to control what happens afterwards?&lt;/P&gt;
&lt;P&gt;Or are you asking how to prevent HTTP errors from ever happening?&amp;nbsp; That sounds much more problematic.&amp;nbsp; Why would you want to prevent the error? How would you know if it worked or not?&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 13:19:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930265#M365993</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-30T13:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to let a macro fail and supress the log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930268#M365994</link>
      <description>&lt;P&gt;The tcperror condition -- when it happens -- is at a lower level than what PROC HTTP can catch/detect and report in the status macro variables. As a very frequent user of PROC HTTP, I see it only when there are network glitches or issues that might be triggered by a firewall or other environmental conditions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My only advice is to make sure you are up-to-date on SAS maintenance/hotfix releases, and ensure your network environment is stable/available during your SAS job run.&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 13:26:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930268#M365994</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2024-05-30T13:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to let a macro fail and supress the log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930270#M365996</link>
      <description>&lt;P&gt;If your goal is to avoid writing any messages to the log, you can redirect the log somewhere else (or to a bit-bucket).&amp;nbsp; On Windows you can do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc printto log='nul' ;
run ;

%put Look Ma no log!  ;

proc printto log=log ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I've never (?) seen a good reason for doing that. I know some companies have a 'no errors in the log' rule, but I don't think that is a reason to turn off the log (and miss all the other important messages you get).&amp;nbsp; In a case like this, I think it's better to add an exception to your log checker, to allow an expected error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't even like turning off MPRINT.&amp;nbsp; The idea of turning off the log completely terrifies me.&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 13:39:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930270#M365996</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-05-30T13:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to let a macro fail and supress the log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930271#M365997</link>
      <description>Hello Chris,&lt;BR /&gt;thats exactly the problem but sadly your solutions cannot be "applied".&lt;BR /&gt;&lt;BR /&gt;Is there not one option avaible, where some workaround might be possible? The error triggers some jobs to fail constantly...</description>
      <pubDate>Thu, 30 May 2024 13:43:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930271#M365997</guid>
      <dc:creator>VIU</dc:creator>
      <dc:date>2024-05-30T13:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to let a macro fail and supress the log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930273#M365999</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/188827"&gt;@VIU&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hello Chris,&lt;BR /&gt;thats exactly the problem but sadly your solutions cannot be "applied".&lt;BR /&gt;&lt;BR /&gt;Is there not one option avaible, where some workaround might be possible? The error triggers some jobs to fail constantly...&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is the problem the job failure, rather than the error message in the log?&amp;nbsp; Often job failure is determined by one of the automatic macro variables that stores error codes.&amp;nbsp; If the job is aborting early due to the error, there are error handling options to prevent that.&amp;nbsp; But I don't think there is the equivalent of a 'CATCH' statement like in an object-oriented language, where you could catch all exceptions to prevent them being raised.&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 13:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930273#M365999</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-05-30T13:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to let a macro fail and supress the log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930277#M366001</link>
      <description>&lt;P&gt;Here's some logic lifted from one of my processes that I had to guard against network issues like this. It does not produce a clean log but it does allow the process to continue gracefully. The first trick is to check for the existence of the SYS_PROCHTTP_STATUS_CODE macro before checking for a value.&amp;nbsp; In my case I built in some retry logic, but if it fails again then I fall through and give up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;    %if %symexist(SYS_PROCHTTP_STATUS_CODE) %then
      %do;
        %if &amp;amp;SYS_PROCHTTP_STATUS_CODE. ne 200 or &amp;amp;syserr. ne 0 %then
          %do;
            %put WARNING: Expected 200, but received &amp;amp;SYS_PROCHTTP_STATUS_CODE., SYSERR = &amp;amp;syserr.;
            %put Waiting 20 seconds to retry...;

            %if &amp;amp;SYS_PROCHTTP_STATUS_CODE. eq 403 %then
             %do;
              %put Refreshing auth token;
               %refreshAuthToken; /* special case where I might need to reauth */
             %end;

            data _null_;
              rc=sleep(20,1);
            run;

            /* call macro that retries here */

            %if &amp;amp;SYS_PROCHTTP_STATUS_CODE. ne 200 or &amp;amp;syserr. ne 0 %then
              %do;
                %put WARNING: Failed again. Expected 200, but received &amp;amp;SYS_PROCHTTP_STATUS_CODE., SYSERR = &amp;amp;syserr.;
                %let msgerr = Process stopped after 2 consecutive failures: &amp;amp;SYS_PROCHTTP_STATUS_CODE., see log;
              %end;
          %end;
        %else
          %do;
            %put HTTP result: &amp;amp;SYS_PROCHTTP_STATUS_CODE. &amp;amp;SYS_PROCHTTP_STATUS_PHRASE.;
          %end;

        %if &amp;amp;syserr. = 0 %then
          %do;
		   /* Process Result Here */
          %end;

      %end; /* SYMEXIST SYS_PROCHTTP_STATUS_CODE */
    %else
      %do;
        %put ERROR: PROC HTTP failed! %superq(syserrortext);
        %let msgerr = Errors in fetching data - see log.;
      %end;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 13:58:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930277#M366001</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2024-05-30T13:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to let a macro fail and supress the log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930372#M366048</link>
      <description>Thanks for your suggestion. I have tried something similar before and like you said before, the problem lays on some other layer/before proc http executes. Hard topic.</description>
      <pubDate>Fri, 31 May 2024 06:48:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-let-a-macro-fail-and-supress-the-log/m-p/930372#M366048</guid>
      <dc:creator>VIU</dc:creator>
      <dc:date>2024-05-31T06:48:52Z</dc:date>
    </item>
  </channel>
</rss>

