11-15-2013 02:52 PM
I am trying to find out how I can direct my SAS data step to act differently based on different conditions.
For ex: If in my dataset condition is true then I want my program to not execute any other piece of code and instead send me an email and if the condition is false then I want SAS to execute the remaining piece of code and not send me an email..
11-15-2013 03:13 PM
Above is about sending e-mails.
I'm guessing that by dataset condition you mean like a property of a dataset and not a variable stored in a row of the dataset but it can technically result in similar approaches. It's difficult without more details about your SAS job but wrapping and nesting the job in a simple data step using if condition with a do block to send e-mail and then stop; statement and and else do block to call execute your wrapped code.
There are probably better solution depending at which point in your process you need to validate that condition whether its an all or nothing or a subtask, etc.
I don't use these features much I'm just a methodologist with a keen interest in programming so I can't provide much more help without you providing far more details. Nonetheless, I hope the above gives you some ideas on how to proceed.
11-15-2013 04:02 PM
Perhaps you need "Put Statement e-mail directives" . A bit more detail about the exact process what help too.
11-18-2013 03:55 AM
put your code in a macro and use a %if sentance , i recoment to create a macro to discribe you "true" condition (proc sql) lets assume you want to count a number of rows in the table and if the amount is more than X do a else do b.
for example :
proc sql noprint;
select count(*) into :mnobs1 from y.table; quit;
%if (&mnobs1. > 10) %then %do;
(add you code for the first condition)
(add you code for the seconed condition)
11-18-2013 09:18 AM
In addition to reading data_null_'s reference about how to send an email, you will also have to provide a little more detail on what should happen.
A data set condition can be true on one observation, and false on another. In fact, it could be true on many observations, and false on many others. What should happen? How many emails do you want to receive? Give us some idea of what you are checking as your "data set condition" and how you know whether it is true or false.
11-21-2013 03:39 PM
1. A macro is, yes, the first solution
2. Here is the basic open-code syntax
Ron Fehd sysfunc+ifc maven