BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Apologies in advance for long winded question but any help would be greatly appreciated
I need some help with a macro that will loop through data and write data to spreadsheet depending on 2 variables (the Branch and the Ref No)

One data set contains sales data. Columns include ‘Branch name’, ‘Policy number’, and ‘Ref No’. This will be a daily programme and the ranges are dynamic.

My aim is to create an excel spreadsheet by branch for any instance, if any, where the ‘Ref No’ field is blank and then email the output as attachment to the relevant branch
If the Ref No field is not blank, no email is required.
I also need some form of summary function so that if there are 3 entries for the London branch with blank Ref No field then 1 email as opposed to 3 is generated .
Code I have so far can only generate output by a predefined excel template and send to one email address so is very limited:



data test1;
set dublindata;
if Refno ne "" then delete;
run;

/*write reults to Excel sheet*/

libname xls pcfiles server=&_clientmachine PORT=8621
path="\\saspcomp01\C\Andy\Testsheet.xls";

proc sql;
drop table xls.Testarea;
quit;

data xls.Testarea(dblabel=yes);
set test1;
run;
libname xls clear;

/*email excel sheet*/

filename mymail email "Blah@blah.co.uk"
subject="Missing Ref No"
attach=("/sas/C/Andy/Testsheet.xls"
content_type="application/excel");
data _null_;
file mymail;
put 'Hi. ';
put 'Could you please provide me with the relevant Ref No for the attached cases. ';
put 'Regards ';
put 'Andy ';

run;
2 REPLIES 2
Peter_C
Rhodochrosite | Level 12
Need some lookup from "branch" to a suitable email address.
Need to decide how to operate over multiple branches : via macros or by-groups.
What are the volumes?
deleted_user
Not applicable
Volumes are relativley small

10 Branches and the daily data set will contain anything between 5 and 50 policies

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 985 views
  • 0 likes
  • 2 in conversation