1

In a job when it reads an empty data set I want it not to abort the job with an error, but to move on to the next scheduled job. Any suggestions on how this can be done?

sushil
  • 1,576
  • 10
  • 14
Daphne
  • 29
  • 3

2 Answers2

3

If you run this code first, to check for existence of the dataset and more than 0 observations, SAS will exit with errorlevel 0 and your scheduler should continue:

%let endsas=;
data _null_;
  if not exist("sashelp.class2") then call symputx("endsas","endsas");
run;
&endsas;
/*Since we are here, the dataset exists, continue to check for 0 obs:*/
%let endsas=endsas;
data _null_;
  set sashelp.class2;
  call symputx("endsas","");*if not 0 obs, this will be executed;
  stop;*Stop, because we only need to run 1 obs;
run;
&endsas;

Note that no code after this will be submitted if the dataset does not exist or is empty.

Stig Eide
  • 1,052
  • 7
  • 14
  • I was thinking of using a macro like anyobs . I am very new at this so thank you for taking the time to answer! – Daphne May 22 '15 at 11:39
  • OK @Daphne, I added check for >0 observations, so now it should exit if dataset does not exist OR number of observations is 0. – Stig Eide May 22 '15 at 12:03
  • 1
    this is a great answer and is going in my tool box! – DomPazz May 22 '15 at 13:54
  • Thank you for the help! The code triggers some other errors unfortunately so I tried the following: I counted the observations, put them in a variable and I want to implement an if statement which if observations=0 will terminate the job. How could I do the if in order to terminate the job? with %goto? – Daphne May 22 '15 at 15:03
  • You need to first check if the dataset exists, then you need to check if there is 0 observations. What kind of errors did my suggestion produce? – Stig Eide May 26 '15 at 06:10
1

Since you are talking about scheduled job which means that you have deployed more than 1 job using DI Studio for scheduling purpose and added all the deployed job that you need to run as a jobstream to a JobFlow in SAS Management Console -> Schedule Manager Plugin.

If this is the case then connecting the jobs in the schedule manager plugin -> schedule flow will popup condition for triggering next di studio jobflow. You can setup condition to trigger the next job regardless of the condition.

Hope this helps.

sushil
  • 1,576
  • 10
  • 14