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

Stopping/limiting the job flow if there empty rows in a source data set? (DI Studio)

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 89
Accepted Solution

Stopping/limiting the job flow if there empty rows in a source data set? (DI Studio)

Working in DI Studio, I have three objects: a SAS Data Set, a List Data transformation for creating a report, and a User Written transformation for sending out emails with the report as an attachment.

If there aren't any rows in the SAS Data Set, I don't want the job to send out an email (the users have no need of being sent an empty report). How do I accomplish this? I assume I need to write something in the precode or code of the User Written transformation.

Thanks for your attention.


Accepted Solutions
Solution
‎09-12-2012 04:18 AM
Super User
Posts: 5,441

Re: Stopping/limiting the job flow if there empty rows in a source data set? (DI Studio)

Posted in reply to TurnTheBacon

precode list:

data _null_;

     dsid = open("&_Input");

     call symputx('NOBS',attrn(dsid,'NOBS');

run;

uaser written:

%macro email;    

%if &NOBS <> 0 %then %do;

          your mail code...

%end;

%mend email;

%email;

Data never sleeps

View solution in original post


All Replies
Super User
Posts: 5,441

Re: Stopping/limiting the job flow if there empty rows in a source data set? (DI Studio)

Posted in reply to TurnTheBacon

In the precode to the list transform, you could have code to check no of observation in the input table, if 0, issue an endsas statement (or abort if you need an rc out from the job).

Data never sleeps
Frequent Contributor
Posts: 89

Re: Stopping/limiting the job flow if there empty rows in a source data set? (DI Studio)

Thanks Linus.

Can someone please give me an idea of what that code might look like though? I'm still not very experienced in writing customized code.

P.S. The entire job shouldn't be terminated, only the part of the job flow that runs through the table without any rows in it. The three objects I described above are parts of a greater job.

Super User
Posts: 5,441

Re: Stopping/limiting the job flow if there empty rows in a source data set? (DI Studio)

Posted in reply to TurnTheBacon

There are some SAS functions that can read metadata about a table, and attrn() will give you no of obs.

The function can be called from a data step or a macro by wrap it in %sysfunc().

If you don't want to terminate the session (meaning you'll have other steps, other than the e-mail sending, afterwards you wish to complete), you code could create a macro variable, which you could analyze in the e-mail step.

Data never sleeps
Frequent Contributor
Posts: 89

Re: Stopping/limiting the job flow if there empty rows in a source data set? (DI Studio)

Thanks again for the advice. As I said I really have no idea how to write it out in the precode though, still being new to this, and new to macros in particular. I'd greatly appreciate an example of what it might look like, if anyone have the time. Then I should be able to modify it to suit my job.

Solution
‎09-12-2012 04:18 AM
Super User
Posts: 5,441

Re: Stopping/limiting the job flow if there empty rows in a source data set? (DI Studio)

Posted in reply to TurnTheBacon

precode list:

data _null_;

     dsid = open("&_Input");

     call symputx('NOBS',attrn(dsid,'NOBS');

run;

uaser written:

%macro email;    

%if &NOBS <> 0 %then %do;

          your mail code...

%end;

%mend email;

%email;

Data never sleeps
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 671 views
  • 6 likes
  • 2 in conversation