Desktop productivity for business analysts and programmers

sending emails from sas proc sql not working

Reply
Occasional Contributor
Posts: 7

sending emails from sas proc sql not working

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;

 

 

Super User
Posts: 9,878

Re: sending emails from sas proc sql not working

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 1 reply
  • 88 views
  • 0 likes
  • 2 in conversation