How can we adapt this to our reporting programs and processes?
- In a BI environment if, for example, a Stored Process report has no data, then the user will either see a blank page or an error message that no output was generated.
- In a batch reporting environment where reports are emailed as attachments, if there is no data, the file may not be created and so the code to email the report will likely fail.
- if you have data, your report is output, but the noDataFoundMessage macro produces no output
- if there is no data, your report code produces no output, but the noDataFoundMessage does
The macro source follows. Feel free to use and share it. I just ask that it's source is acknowledged.
%macro noDataFoundMessage
(Data=_last_,
Message=No Data Found
);
/*----------------------------------------------
Copyright (c) 2008 Henderson Consulting Services
PROGRAMMER : Don Henderson
PURPOSE : Generates a message if the specified
input data set is empty.
Used to prevent the SAS Stored Process Server
from returning the message that no output was
generated for situations where there is no data.
Can be called immediately after reporting code,
using the same input data set, to produce the
custom message if the input data is empty.
---------------------------------------------*/
data nodata;
length msg $128;
if lr then
do; /* no data */
msg = symget("Message");
output;
end; /* no data */
set &data end=lr;
stop;
run;
proc report data = nodata nowd;
columns msg;
define msg / display ' ';
run;
%mend noDataFoundMessage;
No comments:
Post a Comment