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. In my case I built in some retry logic, but if it fails again then I fall through and give up.
%if %symexist(SYS_PROCHTTP_STATUS_CODE) %then
%do;
%if &SYS_PROCHTTP_STATUS_CODE. ne 200 or &syserr. ne 0 %then
%do;
%put WARNING: Expected 200, but received &SYS_PROCHTTP_STATUS_CODE., SYSERR = &syserr.;
%put Waiting 20 seconds to retry...;
%if &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 &SYS_PROCHTTP_STATUS_CODE. ne 200 or &syserr. ne 0 %then
%do;
%put WARNING: Failed again. Expected 200, but received &SYS_PROCHTTP_STATUS_CODE., SYSERR = &syserr.;
%let msgerr = Process stopped after 2 consecutive failures: &SYS_PROCHTTP_STATUS_CODE., see log;
%end;
%end;
%else
%do;
%put HTTP result: &SYS_PROCHTTP_STATUS_CODE. &SYS_PROCHTTP_STATUS_PHRASE.;
%end;
%if &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;
... View more