Desktop productivity for business analysts and programmers

Stop email step in a project?

Reply
N/A
Posts: 0

Stop email step in a project?

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?
N/A
Posts: 0

Re: Stop email step in a project?

Yes.

How depends on how you are doing the email.

The decision can involve wrapping the process in a macro.

If a datastep, SAS may not run the datastep if there is no data;
or you can use the nobs= option to determine if a set dataset has any data in it.

I'm sure there are probably other methods, and things specific to EG that I don't know about.
N/A
Posts: 0

Re: Stop email step in a project?

Sounds promising!

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. Smiley Wink
SAS Super FREQ
Posts: 8,818

Re: Stop email step in a project?

Hi:
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

Then, here are some links to other forums postings that you may find useful:
http://support.sas.com/forums/thread.jspa?messageID=9165⏍
http://support.sas.com/forums/thread.jspa?messageID=7089᮱
http://support.sas.com/forums/thread.jspa?messageID=6402ᤂ
http://support.sas.com/forums/thread.jspa?messageID=5697ᙁ
http://support.sas.com/forums/thread.jspa?messageID=2664੨
http://support.sas.com/forums/thread.jspa?messageID=9438ⓞ
http://support.sas.com/forums/thread.jspa?messageID=9165⏍

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.

cynthia
N/A
Posts: 0

Re: Stop email step in a project?

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!”

http://www2.sas.com/proceedings/sugi31/256-31.pdf

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.
N/A
Posts: 0

Re: Stop email step in a project?

Sending an email from a code block is not hard.

Based on what the others have said/written, and the fact that you want some extra sophistication, I would recommend you use a code block to control sending the email.

The code block can be linked to the appropriate step in the project. There are two ways that I can think of, but explaining how in text isn't necessarily easy.

I have inherited some code that sends emails, but I haven't worked with it yet, so I can't advise any further.
N/A
Posts: 0

Re: Stop email step in a project?

Thank you all so much for the prompt and helpful replies. I'll be looking over these links and will report any progress!
N/A
Posts: 0

Re: Stop email step in a project?

I needed to do this, so here's my code:

[pre]
%let base_file = &BasePath\*.&datestamp..*.&dayofweek. ;

filename logfiles "&base_file..log";
filename notify email 'somebody@someplace.com' subject='SAS email test -- check_for_errors';

data dummy;
length filename prior_file $256 eof 3 dummy $9;
retain dont_send 1 prior_file;
infile logfiles end=eof eof=eof scanover filename=filename ;
file notify;
input @'ERROR' test $;

if length(test) > 0 then do;
dummy = scan(_infile_,1," ");
output;
if dummy in ('RP', 'ERROR', 'ERROR:') then do;
dont_send = 0;
if filename ^= prior_file then do;
put ;
put filename ;
end;
put _infile_ ;
test = "";
prior_file = filename;
end;
end;
return;
eof:
if eof and dont_send then do;
put '!EM_NEWMSG!' ;
put '!EM_ABORT!' ;
output;
end;
return;
run;
quit;

[/pre]

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.
Ask a Question
Discussion stats
  • 7 replies
  • 153 views
  • 0 likes
  • 2 in conversation