Hello,
I'm an inexperienced user of SAS Data Integration Studio.
I would like to receive an e-mail information about the job status. Using "Status Handling" and action "Send Email" (from job options) is not satisfying to me. First of all - (propably?) i can't attach log to this e-mail (maybe there is another option for this job?).
In SAS Enterprise Guide I developed and tested code for sending email with log in attach and some useful informations (datetime, list of errors) in mail body:
%let mail = "test@test.com";
%let path_error = /home/ ... .log;
filename msg email
to = (&maile)
subject = "SAS Message Test"
attach = "&path_error.";
data _null_;
dttm = put(datetime(),nldatm.);
infile "&path_error.";
input;
file msg;
if _n_ = 1 then do;
put "Date time: " dttm;
put;
put "Full log in attach.";
put "There are some ERRORs and WARNINGs:";
put;
end;
if substr(_infile_,1,5) = "ERROR" then
put _infile_;
if substr(_infile_,1,7) = "WARNING" then
put _infile_;
run;
This code works fine - I get complete mail with list of errors and warnings. In log from Enterprise Guide I can see:
NOTE: 268 records were read from the infile "[...].log"
But how to implement this code (especially reading by infile statement) in DIS?
I have modified the job options:
%let path = /home/[...]/log_&etls_jobName._%sysfunc(datetime(), datetime.).log;
proc printto log="&path.";
run;
%let address = "test@test.com";
%let message = problems with &etls_jobName;
filename sendMail email
to= (&address)
subject= "ETL Process problem: &etls_jobName."
attach= "&path.";
options nosyntaxcheck;
data _null_;
dttm = put(datetime(),nldatm.);
infile "&path.";
input;
file sendMail;
if _n_ = 1 then do;
put "Date time: " dttm;
put;
put "Full log in attach.";
put "There are some ERRORs and WARNINGs:";
put;
end;
if substr(_infile_,1,5) = "ERROR" then
put _infile_;
if substr(_infile_,1,7) = "WARNING" then
put _infile_;
run;
In effect I get e-mail with log in attach, but empty body. In attached log I can see:
NOTE: 0 records were read from the infile
I've got some questions:
input;
statement from Postcode and run job I get e-mail with "Date time / Full log in attach / There are some ERRORs and WARNINGs" in body. Why they are deleted where input
works in code?options nosyntaxcheck;
in code. Why?Thanks for the answers. Regards, Michał
Hi,
The answer to your third question may resolve the first two as well.
If there is an error in your SAS session and SAS enters syntaxcheck mode, no later data will be processed, and this would prevent your data _null_ step from reading in the data via the INPUT statement.
I take a similar log emailing approach in my DI jobs. Before your log scanning / emailing code at the end, you can add:
options obs=max replace NoSyntaxCheck;
This basically recovers from syntaxcheck mode, and tells SAS to go back to executing any following data steps.
--Q.
Hi,
The answer to your third question may resolve the first two as well.
If there is an error in your SAS session and SAS enters syntaxcheck mode, no later data will be processed, and this would prevent your data _null_ step from reading in the data via the INPUT statement.
I take a similar log emailing approach in my DI jobs. Before your log scanning / emailing code at the end, you can add:
options obs=max replace NoSyntaxCheck;
This basically recovers from syntaxcheck mode, and tells SAS to go back to executing any following data steps.
--Q.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.