SAS Web Report Studio 4.2 enables you to schedule reports using a method called in-process scheduling. Because the in-process scheduling server runs as a process inside of SAS Web Report Studio, information about scheduled jobs appears in the SAS Web Report Studio log.
In some cases, a failed scheduling attempt means that there is a problem with the report. This sample explains how to create a SAS® Stored Process that you can use to scan the SAS Web Report Studio log looking for failed scheduling attempts. You can include the output of the stored process in a report, which can then be distributed to those responsible for administering reports for your enterprise. The report serves as an alert that some reports might need maintenance.
Because the log file is locked wherever the Web application server is running, you must make a copy of the current log so that the stored process can scan it. In the default installation, the SASWebReportStudio4.2.log
file is typically located in <sas-config-dir>\Lev1\Web\Logs
.
Tip: You can automate the step to copy the log. Automation is not covered in this sample.
Click the Full Code tab to access the stored process code for this sample. Save the code as Check4Failed.sas
and note the location. You need to know the location in order to register the stored process.
c:/storedprocesses
). Check4Failed.sas
.Launch SAS Web Report Studio and create a new report that includes the stored process that you just registered. For help with this task, see Insert a Stored Process.
Below are two views of the report.
Figure 1. This report covers eight days.
Figure 2. This report covers one day.
Save the report and then select File ► Distribute to distribute the report via e-mail as PDF or as embedded HTML to users who are responsible for maintaining reports at your site. For example, if you schedule reports to run each night, then select to distribute this report after that job is finished. (In order to distribute reports, you must be assigned the Advanced Scheduling:Distribute capability. In order to create distribution lists, you must be assigned the Administrative:Manage Distribution List capability.)
For more information about SAS Web Report Studio, see the SAS Web Report Studio documentation page.
For more information about SAS Management Console, see the SAS Management Console documentation page.
For more information about stored processes, see SAS 9.2 Stored Processes: Developer's Guide.
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.
Save the following stored process code, Check4Failed.sas. There are two fields that need to be modified in the Stored Process: Log and Days.
*Processbody;
/* ********************************************************************************************
* Report: Check4Failed.sas
*
* Description: This stored process scans a WRS log and looks for the string "Result: Failed".*
* If it find it then it grabs the report name that failed and outputs the report name and date.
* (This ONLY WORKS WHEN USING THE SAS IN-PROCESS SCHEDULER)
*
* Inputs: log: Location and name of log. Note: You must make a copy of the existing WRS log file.
* days: Number of days from today to go back and check
*
* Outputs: The date and report are output. If there are not any errors then the report field displays the following
* message: "No errors were detected"
*
*
* This is an example of a line in the log that has an error:
* 2010-08-13 15:01:27,165 [WRSThreadPool 1] WARN [c7dc5888b21fcaa8:5ecef553:12a6bc0c619:-6319sasdemo]
* com.sas.apps.citation.model.scheduler.inprocess.WRSExecutionProvider$ScheduledExecution -
* Scheduled batch report for (D71049\sasdemo),
* report (SBIP://METASERVER/Shared Data/Reports/Dummy Report.srx(Report)). Result: FAILED.(0 se
************************************************************************************************* */
%stpbegin;
%let log =C:\SAS\EBIserver\Lev1\Web\Logs\SASWebReportStudio4.2 - Copy.log; /* location and log name */
%let days=1; /* number of day from today to go back and check */
data work.errors (drop = text);
length report $200
date 8;
infile "&log" lrecl=400;
input text $400.;
if index(text, "Result: FAILED") then
do; /* line contains failed */
/* capture the date */
date = mdy(substr(text,6,2),substr(text,9,2),substr(text,1,4));
format date date7.;
start = index(text,"SBIP:");
end = index(text,".srx(Report))");
report = substr(text,start+17,(end-start)-13);
if date >= (today()- &days) then
output;
end; /* line contains failed */
run;
proc sql noprint;
select count(*) into: counter
from work.errors;
run;
%macro output;
%if &counter <= 0 %then
%do;
data work.errors;
length report $200
date 8;date = .;
report = "No errors were detected";
output;
run;
%end;
/* output the results */
Proc sort data=work.errors nodupkey;
By date report;
Run;
title1 "Web Report Studio Reports that Failed During a Schedule Attempt During the past &days day(s)";
proc print data = work.errors noobs;
var date report;
run;
%mend output;
%output; /* run the output macro */
%stpend;
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 Query and Reporting ==> Report Distribution |
Date Modified: | 2010-08-24 10:10:03 |
Date Created: | 2010-08-17 10:05:32 |
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 Server 2003 for x64 | 4.2 | 9.2 TS2M0 | ||||
Microsoft Windows Server 2008 for x64 | 4.2 | 9.2 TS2M0 | ||||
Microsoft Windows XP Professional | 4.2 | 9.2 TS2M0 | ||||
Windows Vista | 4.2 | 9.2 TS2M0 | ||||
Windows Vista for x64 | 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 |