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!
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
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
The following paper talks about a similar problem running batch on UNIX, but it may be the same problem:
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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.