I have configured an EG project to send a dataset to an email recipient as a step in the project. This works GREAT if there is data to send. However, at times, there will be no data so sending an email to the recipient is not desirable.
Is it possible to not process the email step if the data is non-existant?
Basically, I'm running a filter on two datasets to check if there are matching values in 2 particular columns. Regardless, a resulting dataset is generated. However, there may not be matching data, so the result could be empty. If it's NOT empty, I'd like to send an email raising a flag to oncall staff.
So essentially, I just right clicked on the dataset and chose "Send To > Email Recipient as a Step in Project"
I should put a disclaimer saying that I consider myself to be a beginner to intermediate level user and that I'm a point and clicker with very basic knowledge of coding. So actually writing and implementing a macro or code without some details might be tough for me.
Sadly there's not a good point and click way to build a macro program. So you'll have to do it the old-fashioned way -- with code and you'll have to learn the code the old-fashioned way -- by reading the documentation on the SAS Macro facility.
However, as much as I am a fan of the Macro documentation, I also think this is the best paper for learning general macro processing concepts and the programs are not so long that you could NOT make up your own test programs based on the examples in this paper. It even covers conditional processing: http://www2.sas.com/proceedings/sugi28/056-28.pdf
since they either deal with macro issues directly, or with finding out how many observations are in a table and creating a macro variable.
Do not, I repeat, do NOT attempt to change the EG-generated code for your task with macro programs/processing/variables until you understand how and where to make the appropriate changes. That's because, behind the scenes, EG uses and inserts some of its own macro programs and processes into your task code.
If you have trouble figuring out where your EG task code needs to change, then your best bet for help is to contact SAS Technical Support for help with your task.
Within the processing language that SAS uses to send an email, there is capability to stop an email being sent. In the following paper from SUGI, you will find a reference to the command directive “!em_abort!”
This will require your manually coding the email data step, but it is substantially more powerful than the point and click solution. All you need is a code node and the data step. You can conditionally send this command, so you can test for observations, or particular values in the step as you build the email and then either allow it to send, or abort the transmission.
There are a number of examples in the tutorial that should assist you, otherwise post more specific information here.
if length(test) > 0 then do;
dummy = scan(_infile_,1," ");
if dummy in ('RP', 'ERROR', 'ERROR:') then do;
dont_send = 0;
if filename ^= prior_file then do;
put filename ;
put _infile_ ;
test = "";
prior_file = filename;
if eof and dont_send then do;
put '!EM_NEWMSG!' ;
put '!EM_ABORT!' ;
I had to use the EOF= option because if the scan for 'ERROR' turned up nothing, none of the rest of the code would actually execute, since there would be no (0) observations for the datastep.