BookmarkSubscribeRSS Feed
Pavan4
Calcite | Level 5

The following code generate  a report .

proc sql;

SELECT PROMO_NBR, PROMO_DESC, Count(PID) as Total FROM eza_lead_report GROUP BY PROMO_NBR, PROMO_DESC;

quit;

 

The report should shared by email.

 

Error message :

ERROR: Email: The connection was refused.

 

Email code for using :

...............................................................................................................................................................

FILENAME outmail EMAIL

SUBJECT="Results as of %sysfunc(date(),yymmdd10.)"

FROM= "ex10testq@mtbdev.com"

TO= "pmuttineni_contractor@mtb.com"

ATTACH= "/madata/MAExports/LeadFiles/data.pdf";

FILENAME output EMAIL

SUBJECT= "EZA Leads Report Summary"

FROM= "ex10testq@mtbdev.com"

TO= "pmuttineni_contractor@mtb.com"

CT= "text/html" ;

ODS HTML BODY=output STYLE=sasweb;

TITLE JUSTIFY=left

"Total Sales by Country and Product type as of %sysfunc(date(),yymmdd10.)";

 

/*PROC REPORT DATA=eza_lead_report NOWD

STYLE(REPORT)=[PREHTML="<hr>"] ;

COLUMNS PROMO_NBR PROMO_DESC,Count;

DEFINE PROMO_NBR /GROUP;

DEFINE PROMO_DESC/GROUP;

DEFINE PID/SUM ;

RUN;*/

title1 "Report genarated on %sysfunc(date(),worddate18.)";

 

 

proc sql ;

create table eza_lead_report as select * from Standard;

quit;

proc sql;

SELECT PROMO_NBR, PROMO_DESC, Count(PID) as Total FROM eza_lead_report GROUP BY PROMO_NBR, PROMO_DESC;

quit;

ODS HTML CLOSE;

DATA _NULL_;

FILE outmail;

PUT "Here are the results for your last query";

RUN;

 

 

1 REPLY 1
Kurt_Bremser
Super User

You need to make sure that your SMTP access is correctly configured into SAS.

See here: http://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.3&docsetId=lesysoptsref&docsetTarget=...

(Category Communications: email)

And your code would send two emails, as the ods html close would close the first email, and the data step another one.

Your final piece of code should be

data _null_;
file print;
put "Here are the results for your last query";
run;

ods html close;

You could also use ods text to insert text into the stream.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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