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 Hackathon registration is open! Build your skills. Make connections. Enjoy creative freedom. Maybe change the world.

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 Hackathon registration is open! Build your skills. Make connections. Enjoy creative freedom. Maybe change the world.

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1805 views
  • 1 like
  • 2 in conversation