BookmarkSubscribeRSS Feed
DerekCruik
Calcite | Level 5

I have a program that pulls in multiple reports; however, many of the reports fail to run at night.  I've created a macro that, if there is an error (i.e. Physical File Doesn't Exist), then the SAS Program closes with an %Abort statement, and an email is sent to an email address stating the program failed to run.  When I run this program manually, and purposely make the program error out, everything works fine and the email is sent.  When I schedule this program to run automatically, using Windows XP Scheduled Tasks, my program errors out and prevents SAS from running; however, the email is not being sent.  There is no message in the log about the email either (not even that it failed).  I was hoping somebody could help me with this issue?  Is it my program or macro, or is this a Windows Scheduler issue?  Thank you!

4 REPLIES 4
art297
Opal | Level 21

Difficult to say without seeing more.  Did you correctly follow the steps as shown in the following paper?:

http://www.pharmasug.org/proceedings/2011/AD/PharmaSUG-2011-AD11.pdf

DerekCruik
Calcite | Level 5

Hello Art.  Thanks for your response.  I've actually set it up multiple ways, the current way is the exact way that paper tells me to by using a batch file.  Below I've provided my macro code as well as the sas log of (1). Running it manually, and (2). Running it through windows scheduler:

Macro

%Macro Runquit;

;run;quit;

%if &syserr. ne 0 %then %do;

%if &syserr. ne 0 %then %do;

%if &syserr. ne 0 %then %do;

         Filename mailbox Email To = "name@email.com"

         Subject = "SAS Error Email";

         Data _NULL_;

         File mailbox;

         PUT "Test email from SAS. You're program is missing a report.";

         Run;

       Proc Printto;

       Run;

     %abort return;

     %end;

%mend Runquit;

Manually Ran Log

ERROR: Physical file does not exist, \\corpfs\sys\Home\ASG
       Production\In\Daily_Debtor_Report_20-2011-18-20*.csv.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.DEBTOR_20_CURRENT may be incomplete.  When this step was stopped
         there were 0 observations and 7 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds
     

NOTE: The file MAILBOX is:
      E-Mail Access Device

Message sent
      To:          "name@mail.com"
      Cc:         
      Bcc:        
      Subject:     SAS Error Email
      Attachments:
NOTE: 5 records were written to the file MAILBOX.
      The minimum record length was 1.
      The maximum record length was 57.
NOTE: DATA statement used (Total process time):
      real time           0.26 seconds
      cpu time            0.06 seconds

Windows Scheduler Ran Log

ERROR: Physical file does not exist, \\corpfs\sys\Home\ASG
       Production\In\Daily_Debtor_Report_20-2011-18-20*.csv.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: SAS set option OBS=0 and will continue to check statements.
      This may cause NOTE: No observations in data set.
WARNING: The data set WORK.DEBTOR_20_CURRENT may be incomplete.  When this step was stopped
         there were 0 observations and 7 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds
     


42                                       The SAS System            16:18 Friday, August 19, 2011


NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

Art, could you tell me, if you know, when a SAS Program is being ran by windows scheduler, is that program then ran in Batch Mode?  Would batch mode have different syntax to send an email than sending an email in Interactive Mode?  Thanks a bunch Art, I really appreciate it!

-Derek

art297
Opal | Level 21

The following paper talks about a similar problem running batch on UNIX, but it may be the same problem:

http://www.lexjansen.com/pharmasug/2010/cc/cc05.pdf

Tom
Super User Tom
Super User

When this issue has been mentioned before it is usually related to the user not being allowed to send email from the process started by Windows Scheduler.  You need to check how to enable access to your mailbox for sending email.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 4 replies
  • 1274 views
  • 0 likes
  • 3 in conversation