BookmarkSubscribeRSS Feed
SanjayM
Calcite | Level 5
I have some requirement where I have to generate reports for different departments

I have a project in Enterprise Guide. On executing this project a txt report is generated that has data of multiple departments. A Stored Process is created out of the EG project and scheduled.

Is there any mechanism where this scheduled stored process when run sends the department output to individual departments mail id.

Stored Process when run gives consolidated output as shown
=============================================
Department Emp Salary
10 1001 50000
10 1002 40000
20 1003 50000
20 1004 55000
30 1005 50000
30 1006 50500
40 1007 50400


Requirement
=========================
Department 10 user should receive the below output in email

Department Emp Salary
10 1001 50000
10 1002 40000

Department 20 user should receive the below output in email
Department Emp Salary
20 1003 50000
20 1004 55000


Department 30 user should receive the below output in email
Department Emp Salary
30 1005 50000
30 1006 50500


Department 40 user should receive the below output in email
Department Emp Salary
40 1007 50400


Second part of the requirement is to send this output to individual department printers

Whats the power of SAS with such a requirement.
1 REPLY 1
deleted_user
Not applicable
Well Grasshopper, I realise that birds are your enemies, and that any reduction in their population might be advantageous to your family. Killing trees for production of paper also reduces birds nesting sites, but that is a poor reason to use a lot of paper. The world is an holistic environment and there is a place for everything in the Lord G*d's realm.

Seriously though, I strongly counsel against automatically sending output to a printer unless there are stringent controls to prevent the printer bins being emptied by an accidentally oversize output file. Almost nobody reads 100 pages of overblown output and you just wasted trees and carbon. However, if you can be sure that you won't kill a tree (by trapping and limiting allowable output quantity), then the PrintTo Procedure allows output to be routed to a destination by specifying the network address of the printer.

Note that the printer must be reachable from the server, so there may be problems sending to a Windows defined printer from a Unix Application server. Since you will invoke the procedure and close it around the output step, you will need to divide the data set and send it in pieces to the PrintTo and Report steps.

As for emailing results (which is a much more conservative and attractive solution), assuming your application server has the capability to send email through your SMTP accessible Post Office server, then simple data step directives will allow you to define and change email addresses as you process the data in a single data step. With a format procedure you can map department values to email addresses and switch email destinations as you step through the data.

A tutorial on "Emailing from your SAS session, how and why" from SUGI 31 is available on the SAS Support web site. Look towards the end where I specified changes of destinations according to strata of house prices. Your code would be very similar.

Kind regards

David

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 531 views
  • 0 likes
  • 2 in conversation