BookmarkSubscribeRSS Feed
sasuser_sk
Quartz | Level 8

Hi Everyone - I have this preview code from SAS EG with the result shown below. I prefer to send email via SAS (includes 2 excel attachments) and in the body of email I want to include the last cumulative frequency (20726) along with the message. Right now, I type the number in email and attach those two excel files manually. It will make my life a little easier if I can at least automate this process by sending email directly. I have this sample email code and would like to add the number somewhere in data step. Is this even doable or I'm over complicating the idea? Any help or suggestions would be greatly appreciated. Thank you.

 

PROC SQL;
CREATE VIEW WORK.SORT AS
SELECT Prod_NM
FROM WORK.QUERY_FOR_DUPLICATEREMOVAL_0000 as T
;
QUIT;

TITLE;
TITLE1 "One-Way Frequencies";
TITLE2 "Results";
FOOTNOTE;
FOOTNOTE1 "Generated by the SAS System (&_SASSERVERNAME, &SYSSCPL) on %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) at %TRIM(%SYSFUNC(TIME(), TIMEAMPM12.))";
PROC FREQ DATA=WORK.SORT
ORDER=INTERNAL
;
TABLES Prod_NM / NOPERCENT SCORES=TABLE;
RUN;

Prod_NM Frequency Cumulative Frequency
Prod1 23 23
Prod2 6322 6345
Prod3 40 6385
Prod4 5673 12058
Prod5 49 12107
Prod6 1861 13968
Prod7 875 14843
Prod8 4330 19173
Prod9 1553 20726

 

%let Todays_Date = %sysfunc(date(), date9.);
%let Attachment_File = "/sasdata/Tracking.xlsx";
%let Attachment_Type= "application/xlsx";

 

options emailsys=xxxxx emailhost=xxxx.com emailport=222;
filename MailBox email
to = ( "bbb.aaa@zzz.com")

from = "bbb.aaa@zzz.com"
subject = "Tracking - &Todays_Date."
;

data _null_;
file MailBox;
put '!EM_ATTACH! (&attachment_File. content_type=&attachment_Type.)';
put 'Hey,';
put ' ';
put "Attached is the tracking report.";
put ' ';
put 'Let us know if you have any questions';
put ' ';
put ' ';
put '-Mmmmmm';
run;

 

1 REPLY 1
jimbarbour
Meteorite | Level 14

If it were me, I would not try to put the Freq results in the body of the email.  If the Freq results are plain text (as in an old .lst file), who knows what font the recipient's email will be displayed in?  The results could be so misaligned as to be unreadable.  If the results are HTML, you could try it and see if it works, but I would think that simply attaching the Freq results would be more reliable.  Again, it's difficult to know what a recipient's email system will do with an email that is part plain-text and part HTML.

 

Jim

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 745 views
  • 0 likes
  • 2 in conversation