Hi,
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
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));
%end;
%else %do;
%put WARNING: Unable to open &dsn;
%put %sysfunc(sysmsg());
%end;
%* Return the number of observations;
&nobs
%mend obscnt;
in your program you might use it something like:
%if %obscnt(mydata)>25 %then %do;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.