Hello Everyone,
I need one help. I have written one piece of code where based on certain conditions, SAS shoots an email to users notifying an event. For example, if there is a file missing or count of records zero in a file. The issue is when I run the code in SAS EG, it shoots an email with email sent log, but when I schedule the same code in SAS Management Console it does not send the email.
I do not face any issue running the code manually in SAS EG, however while scheduling it does not send the email. Do I need to activate some additional settings in Management Console to enable in sending email? What can be the reason for it? Let me know if you need more information
Below is the sample macro which I execute in the main body of the code and also invoke it
%MACRO countobs (outtablename,filename );
proc sql noprint;
select count(*) into: chk
from &outtablename.;
quit;
%PUT &chk ;
%IF &chk LE 0 %THEN %DO ;
options emailsys =smtp
emailhost=smtp.#######@#######.com
emailid="#######@#######.com"
emailpw="#######@#######"
emailauthprotocol=login;
filename myemail EMAIL
to="#######@#######.com"
cc=("#######@#######.com" "#######@#######.com" "#######@#######.com")
subject= "&filename. is blank for &filename_dt. ";
DATA _NULL_;
FILE myemail;
PUT "Hello";
PUT "&filename. is blank for &filename_dt. and SAS session will be aborted";
PUT "Please note this is an automatic email sent from the system due to zero records in the &filename. file today";
RUN;
%abort cancel;
%end ;
%MEND countobs ;
%countobs(&outtablename,&file_name);
Do you have a SAS log for the scheduled job where the e-mail isn't sent? A successful run would show something like:
NOTE: The file MSG is: E-Mail Access Device Message sent To: "recipient@company.com" Cc: Bcc: Subject: your subject line Attachments:
Do you have a SAS log for the scheduled job where the e-mail isn't sent? A successful run would show something like:
NOTE: The file MSG is: E-Mail Access Device Message sent To: "recipient@company.com" Cc: Bcc: Subject: your subject line Attachments:
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: