BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rodrichiez
Quartz | Level 8

@Peter_C

 

 

filename mylog1 "/sasdata/user_Data/log.log";

proc printto log=log;
run;

data _null_;
 infile mylog1 ;
 input;
 put _infile_;
run;
Peter_C
Rhodochrosite | Level 12
Would it not be sufficient to test &SYSCC (or is it sysrc) ?
Peter_C
Rhodochrosite | Level 12
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/tw3514-syscc-var.htm
SYSCC is defined as end-of-job status, but appears to provides the max value (so far) of SYSERR during the job
s_lassen
Meteorite | Level 14

Rather than looking af the SYSERR Automatic variable, I would use the SYSCC variable.

 

It has two advantages:

  1. You can set it whenever you want, with %LET SYSCC=0
  2. It does not get reset by SAS, meaning that it contains the maximum error level encountered since you last set it

So I would start with 

%let SYSCC=0;

SAS CODE here

%let check=&SYSCC;

Then, after the SAS code submitted, &SYSCC contains the maximum error level encountered, which you save in your CHECK variable.

In which case you may want to change the "if &check>0 then do;" in your log gathering datastep to "if &check>4 then do;" as level 4 is just a Warning, and apparently you do not want to report those.

 

I do not see how you send your mail, allocating the EMAIL file is not enough. So I presume that you have a datastep in the end to send the mail. If things are OK, and you do not want to send the mail, just put this in your datastep:

 

Data _null_;
  file outbox <options>;
  if &check<=4 then do;
    put "!EM_ABORT!";
    stop;
    end;
  

The !EM_ABORT! message tells SAS not to send the mail after all.

 

rodrichiez
Quartz | Level 8

Thanks @s_lassen I'll try this. By the way, the email is sent by the code:

 

filename outbox email attach=("/sasdata/user_Data/reportlog.txt") importance='high'

       to='chrodriguez@com.do'
       type='text/html' 
       subject= "Log ETL"
       from='planificacion@com.do';

DATA _NULL_;
FILE outbox;

PUT "<body>";
PUT "<p>Hello, </p>";
PUT "<p>The program executed with erros, see attached file.</p>";
PUT "<p>Regards.</p>";
PUT "</body>";

run;
run;

The file attached contains only the errors and warning messages from the log.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 19 replies
  • 7012 views
  • 10 likes
  • 5 in conversation