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

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);

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

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: 
SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

View solution in original post

1 REPLY 1
ChrisHemedinger
Community Manager

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: 
SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

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
  • 1 reply
  • 2442 views
  • 1 like
  • 2 in conversation