BookmarkSubscribeRSS Feed
AK100
Pyrite | Level 9

Hello All,


I have a data-project in SAS EG (which is connected to SAS VA through LASR Tables). Now this data-project is being runned 2x a day automatically through the SAS management console and the task scheduler (so it is being updated 2 times a day). It is a fully automated data-set, which means that I won't check everyday if the data is realistic. It is only the end-user who sometimes tells he sees some strange values or blank fields. 


Now I want the following, I want to receive an alarm message (preferable in the form of an email) if the data that is being updated is not valid. Just to give some examples: If the column speed for example contains an unrealistic value (with a 9 digit) while the normal speed should be somewhere between 0 - 200 KM/H, or if some fields are blank fields or like some datevalues are unrealistic. 

 

Any deviation should cause the alarm to go off and send me (and others!) an e-mail (text-message, or something else, if you have any ideas?) so I can check why the data is not being updated in a correct manner. (In my head I already have made a list which could cause possible deviations).

 

I hope someone has a great idea, I appreciate your help. Thank you in advance 

3 REPLIES 3
AK100
Pyrite | Level 9
Maybe there is an easier way to put in alerts through SAS VA or something like that? Its always good to try and view a problem from multiple angles. That by the way, does not mean your answer is not working.. I just cant figure out what you exactly did there.
Kurt_Bremser
Super User

The code example, annotated:

%let detect=0; /* "false" */
/* set a macro variable to an initial value that indicates a logical "false", or "no" */

/* the next might be your penultimate data step in the chain of your processing */
/* select any step in which you can detect all your possible error conditions */
/* meaning: all checkable variables have been set to their final values which can be tested for plausability */ 
data next_step;
set from_previous_step;
/* processing */
/* whatever you already have been doing here */
if missing(variable) then call symput('detect','1');
/* one possible error condition */
/* you can insert any number of conditions here, any one will set the macro variable to a logical "true" (1) value */
run;

/* now we test for that value */
%if not &detect. %then %do; /* we have not found an error */
/* create final table */
%end;
%if &detect. %then %do; /* we have found an error */
/* send email */
%end;

Since I use %if-%then-%do-%end in open code, you need to be at least at SAS 9.4 M5, as this feature was introduced in this maintenance level. If you are before that, you need to wrap this part into a macro definition.

Examples for sending email from code can be found in the documentation for FILENAME Statement: EMAIL Method .

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 772 views
  • 0 likes
  • 2 in conversation