In SAS Web Report Studio, if a prompt does not return any results, you are presented with an empty report. This sample shows you how to provide an informative message when no results are returned.
This sample uses an information map that was created using the data set SASHELP.CLASS. You can use your own data to follow along.
This sample involves using a stored process to preprocess the data for the information map. The sample assumes that you have an understanding of SAS programming because the code is not explained in detail.
You can submit the code in an interactive Base SAS® session or in a SAS® Enterprise Guide program node. Use whichever application you are most comfortable with.
This sample was written using the second maintenance release for SAS 9.2 (TS2M2).
The following sample code adds two variables named Date and Message to a table named mydates that is based on SASHELP.CLASS. The first observation (_N_) is set to the current date. The date is then incremented by 1 for each record. Modify the code for your environment, and then submit it.
LIBNAME Orion BASE "C:\Orion\date";
data Orion.mydates;
length message $60;
set sashelp.class;
retain date;
if _n_ = 1 then
date = today();
date = date + 1;
format date date7.; output;
run;
|
The following stored process code takes input from a prompted macro called Indate.
LIBNAME Orion BASE "C:\Orion\data";
libname biout (work);
%global indate;
/* See if any rows are returned when subsetting on prompted date */
/* A macro called rownum is created that contains
the number of rows returned */
proc sql;
select count(*) into: rownum
from orion.mydates (where=(date = "&indate"d));
quit;
/* Create a macro that check the value of rownum */
%macro checkit(row);
%if &rownum >= 1 %then
%do;
data biout.mydate;
set orion.mydates (where=(date = "&indate"d));
run;
%end;
%else
%do;
data work.mydate;
set Orion.mydates (obs=1);
Name='';
Sex='';
Age=.;
Height=.;
Weight=.;
Message = "The date was invalid. No rows were returned";output;
run;
%end;
%mend checkit;
options mprint symbolgen;
/* execute the macro, passing in the number of rows */
%checkit(&rownum);
run;
%stpend;
|
Using the stored process created previously, follow the instructions in Sample 39432: Associating an existing SAS Stored Process with an information map in SAS Information Map Studio 4.2 .
Figure 1. Valid date displays a title in the message box
Figure 2. Invalid date displays descriptive message
For more information about SAS Information Map Studio, see the SAS Information Map Studio documentation page.
For more information about stored processes, see SAS 9.2 Stored Processes: Developer's Guide.
For more information about SAS Web Report Studio, see the SAS Web Report Studio documentation page.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
Type: | Sample |
Topic: | Query and Reporting ==> Interactive Querying |
Date Modified: | 2010-05-11 14:44:50 |
Date Created: | 2010-05-06 14:43:23 |
Product Family | Product | Host | Product Release | SAS Release | ||
Starting | Ending | Starting | Ending | |||
SAS System | SAS Web Report Studio | Microsoft® Windows® for x64 | 4.2 | 9.2 TS2M0 | ||
Microsoft Windows Server 2003 Datacenter Edition | 4.2 | 9.2 TS2M0 | ||||
Microsoft Windows Server 2003 Enterprise Edition | 4.2 | 9.2 TS2M0 | ||||
Microsoft Windows Server 2003 Standard Edition | 4.2 | 9.2 TS2M0 | ||||
Microsoft Windows XP Professional | 4.2 | 9.2 TS2M0 | ||||
Windows Vista | 4.2 | 9.2 TS2M0 | ||||
64-bit Enabled AIX | 4.2 | 9.2 TS2M0 | ||||
64-bit Enabled Solaris | 4.2 | 9.2 TS2M0 | ||||
HP-UX IPF | 4.2 | 9.2 TS2M0 | ||||
Linux for x64 | 4.2 | 9.2 TS2M0 | ||||
Solaris for x64 | 4.2 | 9.2 TS2M0 |