SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Stop DI job for blank data set

Reply
Contributor
Posts: 64

Stop DI job for blank data set

[ Edited ]

I have a job that will check if a certain date exists in a data set.

 

If it does I want the next few nodes of the job to execute, if not I want the job to stop completely.

 

How can this be done?

 

Thanks

Aidan

Super User
Super User
Posts: 7,993

Re: Stop DI job for blank data set

Ca you use SAS code?  If so:
%if %sysfunc(fileexists(...)) %then %do;

...

 

Or sort data nodupkey to create a dataset, then check sashelp.vtable:
data _null_;

  set sashelp.vtable (where=(libname="<libname>" and memname="<dataset>" and nobs > 0));

  call execute('%include <next job>'Smiley Wink;

run;

 

Will only call the execute if more than 0 obs.

Super User
Posts: 5,438

Re: Stop DI job for blank data set

@RW9 example would certainly work programming wise, but it's not really DI Studio best practice...

You could use the same logic with an Extract, and have that as output to a Loop. No entries in the look up table, no loops.

Another option is to use post cade in the extract, if the result table is empty, execute endsas/abort abend etc.

Third option is try to use the Conditional Start/End transformations.

Data never sleeps
Contributor
Posts: 64

Re: Stop DI job for blank data set

I have tried a conditional start and end as per attached however it seems to just stop on conditional start

Super User
Posts: 7,859

Re: Stop DI job for blank data set

Just for reference, Aidan has asked related questions in

https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339634

and

https://communities.sas.com/t5/SAS-Data-Management/Conditional-Start-amp-End/m-p/340000

 

Personally, I would dissect the job into its parts and have the scheduler handle the continuation conditions, controlled by return codes from the single jobs, or by the execution date as such.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 64

Re: Stop DI job for blank data set

Posted in reply to KurtBremser
@KurtBremser I needed some more direction so had to post a new thread as it could be that I am approaching this incorrectly. Very new to writing on the fly SAS code so need more direction on this,
Super User
Posts: 7,859

Re: Stop DI job for blank data set


Aidan wrote:
@KurtBremser I needed some more direction so had to post a new thread as it could be that I am approaching this incorrectly. Very new to writing on the fly SAS code so need more direction on this,

No problem. I just wanted to give everybody new to the topic a chance to see what was already talked about. Otherwise I'd have merged the threads into one, but I see an evolution of the theme(s) Smiley Wink

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 64

Re: Stop DI job for blank data set

Posted in reply to KurtBremser

I have pre code in an extract node to check if data set is blank;

data _null_;
dsid = open("&_Input");
call symputx('NOBS',attrn(dsid,'NOBS');
run;

 

I will only then e-mail the results if the data set is not blank as per below;

PROC EXPORT DATA=work.W4JQ299
OUTFILE="\\test\my file.csv"
DBMS=CSV Replace;
PUTNAMES=YES;
RUN;

%macro email;
%if &NOBS <> 0 %then %do;
data _null_;
file sendit email
from="from"
to=("to")

subject="test"
attach=("\\test\my file.csv");
put "Hi all,";
put;
put "xxxxxxxxxxxxxx";
put;
put "Kind Regards,";
put "Aidan";
run;

%end;
%mend email;
%email;

 

The email code doenst seem to be working, any ideas?

I have removed the e-mail address and file location for security on here

 

Thanks

Aidan 

Super User
Posts: 7,859

Re: Stop DI job for blank data set

Use ne instead of <> in the %if condition.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 8 replies
  • 181 views
  • 0 likes
  • 4 in conversation