Help using Base SAS procedures

Export to Excel and Email for Multiple Recipients

Reply
Contributor
Posts: 25

Export to Excel and Email for Multiple Recipients

[ Edited ]

Hello,

 

I'm working with a dataset that has a list of action items where each action item has the owner name. Note that some owner has more than one action item.

 

My goal is to take the list of action items, divide them up by each owner, and email that Excel sheet to each owner. I'm pretty new to SAS Macros and I'm having difficulty thinking of what's the best way to do it. Currently, I'm writing code specific to each owner:

 

data ownername1;

set all;

if owner=owner1;

run;

 

data ownername2;

set alll

if owner=owner2;

run;

 

etc...

 

Then I'm going to proc export for each owner dataset and have SAS email out that report, however, I don't want an email to be sent if there are no action items. Clearly this is taking a lot of time and I can't help but think there's a better way to do this. Any ideas to get me started?

 

Thanks,

 

Derek

Super User
Posts: 19,878

Re: Export to Excel and Email for Multiple Recipients

Posted in reply to dereck255

Hard to say with just what you've posted here. It depends on how much difference there is between each 'action'.

 

It could be easy to say, create a macro for each action and then use call execute to loop through your list and execute the correct macro for each user. 

Or a generic macro that takes the action for each user and somehow filters out the correct action so the action is a parameter to the macro. 

Contributor
Posts: 25

Re: Export to Excel and Email for Multiple Recipients

Hi Reeza,

 

There's no real difference between the actions. Either the "Description" column has some detail in it, or it's blank (blank meaning that there are no action items). 

 

Do you have any basic macro literature I can look at? I've googled my situation and the macros that might be helpful are way too complex for me at this point.

 

Thanks!

Super User
Posts: 19,878

Re: Export to Excel and Email for Multiple Recipients

Posted in reply to dereck255

Basic Intro here:

http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/

 

Then read through the examples:

https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Ap...

 

The examples have most of what people should need for a starter. 

Then search through lexjansen for any number of papers on the topic:

http://www.lexjansen.com/phuse/2014/cc/CC06.pdf

Ask a Question
Discussion stats
  • 3 replies
  • 397 views
  • 0 likes
  • 2 in conversation