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: 
Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

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: 
Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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