send auto emails after a sanity check

Frequent Contributor
Posts: 134

send auto emails after a sanity check



We send out reports via email. we have one project for each report and each report is sent out individually to multiple recipients


usually we run the sas code that generates an output in excel and then we manually send our emails and make attachments. The reason we do it is to ensure that we are not sending out garbage files (incase data is missing)


is there a way we can automate this process (with some sanity check, something like do a count of records and if the count is in between a defined range for the given report then send it out otherwise generate an error email to notify whoever looks after that report)?


Please assist


Thanks, in advance

Valued Guide
Posts: 653

Re: send auto emails after a sanity check

Assuming that your check will be against the observation count in a data set, here is a little macro that i use to return the number of observations in a data set.

%macro obscnt(dsn); 
%local nobs dsnid rc;
%let nobs=.;

%* Open the data set of interest;
%let dsnid = %sysfunc(open(&dsn)); 

%* If the open was successful get the;
%* number of observations and CLOSE &dsn;
%if &dsnid %then %do; 
     %let nobs=%sysfunc(attrn(&dsnid,nlobs));
     %let rc  =%sysfunc(close(&dsnid)); 
%else %do; 
     %put WARNING: Unable to open &dsn;
     %put %sysfunc(sysmsg());

%* Return the number of observations;
%mend obscnt;

in your program you might use it something like:

%if %obscnt(mydata)>25 %then %do;
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation