Please help me with the code for the below mentioned requirements:
1. To generate a consolidated report file (text output) for all regions.
2. To send the output of each region seperately to the Region's printer.
/* S A S S A M P L E L I B R A R Y */
/* NAME: STPODS1 */
/* TITLE: Reporting with the Output Delivery System (1) */
/* PRODUCT: SAS Integration Technologies - Stored Process */
/* SYSTEM: ALL */
/* KEYS: */
/* PROCS: GCHART, FREQ, REPORT */
/* DATA: SASHELP.SHOES */
/* SUPPORT: Web Tools Group UPDATE: January 2003 */
* This sample program creates a horizontal bar chart and a table of
* output from the Freq procedure. You can click on the bar chart
* to see additional information generated by Proc Report.
* The STPBEGIN and STPEND macros are used to automatically issue
* the appropriate ODS statements to support streaming HTML output
* back to the client application. Documentation for these macros
* can be found at
title "Men's and Women's Shoe Sales Figures by Region";
* Generate 3D horizontal bar chart;
/*ods listing close;
ods html body=_webout
title 'Stock Prices';*/
proc report data=sashelp.shoes nowd FORMCHAR='-';
column region product stores sales returns inventory;
title 'Test Title';
define region / group noprint;
define product / group ;
define stores / order;
define sales/ sum order;
define returns /order ;
define inventory/ sum 'Inventory' format=dollar16.2;
break after region /skip ol;
break after product / skip ol;
compute before region;
line ' ';
line @60'Region: ' region $25. ;
line ' ';
compute after product;
line @60 'SubTotal for ' product $20. @98 inventory.sum dollar16.2;
compute after region;
line @60 'Region Total '
line 'Grand Total ' @58 inventory.sum dollar16.2;
*ods html close;
I have a hard time understanding what you want. This program (stored process?) that you've attached looks like it will generate the report for ALL the regions. Do you mean that you ALSO want this stored process to "automatically" generate another set of reports -- one for each region AND you want the stored process to send the report AUTOMATICALLY to each region's printer?
To do that, you would need a second PROC REPORT step in this stored process or a separate stored process to generate a separate report for EACH region. There are several ways to do it. I would probably use a macro program to generate a report for each region. I don't think I would design one stored process to do the consolidated report and the report for every region. I'd keep them separate because then they'd be more re-usable that way -- you could get the consolidated report without getting the reports for every region or vice versa. Again, macro programs would help you out a lot here, because you could use a macro %do loop to cycle through all the regions or you could use macro logic to bypass the %do loop and generate a report for only 1 region. Tech Support can help you with the syntax to generate a report for each region -- either macro progam syntax or PROC REPORT syntax.
But, then, I would probably approach the problem in a different way:
1) make one stored process for the consolidated (All region) report
2) make a second stored process that would run for just 1 region
-- either invoke this second stored process using the Stored Process Web App -- so you could execute it from a script
-- or write a JSP or Java app to execute the stored process
-- or write a .NET app to execute the stored process
if you invoked the second stored process (assume it was called OneRegion) using the SPWA, you could do this:
Run for Asia</a>
Run for Canada</a>
I would NEVER try to send output directly to a printer unless I knew it was constantly monitored, always supplied with paper, somebody right there to troubleshoot problems, kind of printer. And even then, I probably wouldn't do it. Stuff happens to printers all the time...and if something happened, you'd have to rerun the SP to regenerate the output -- so you're back to needing a SP that you can invoke for just 1 region again. And, besides, I don't even think it's possible -- easily -- to send SP output directly to a printer. I could be wrong on this, but my idea of "easily" doesn't involve writing a custom front end or custom script -- which is what I think might be involved.
But, if you want to find out whether it's even possible to direct stored process output directly to a remote printer, you would have to contact Tech Support. This almost sounds like a job for a regular old batch job and not a stored process.
My approach would be a bit different. If I really needed to generate a report for EVERY region, I would have a folder or folders on a server and I'd generate my report for each region and stick the report in that folder. Then somebody in the region could come in every morning and print what was in the folder on the server. Every night or every xx number of days, I'd write my output to that folder -- either clearing out what was there or by putting out a report with a specific name that had the date embedded in it.
In any case, your best bet for help is to contact Tech Support.