BookmarkSubscribeRSS Feed
CamRutherford
Fluorite | Level 6

Hello,

 

I have the below code which looks at exporting the datasets. However, I'd like the email to have the HTML results attached as a PDF instead - any ideas?

 

%let user = crf;
%let dataset=CIRC;
%let dataset1=/user/&user/CIRC.csv;

Data &dataset;
set CIRC;
run;
proc export data=&dataset
   outfile="&dataset1"
   dbms=csv
   replace; 
   run;

***update email recipients here***;
filename mymail email 
   To=("cameron.test@test.com" )
   subject="Circulation Report -  Prev 90 days"
   attach=("&dataset1");

data _null_;
   file mymail;
   put "Hello,";
   put " ";
   put "Please see the attached circulation file for campaigns sent in the last 90 days.";
   put " ";
    put "This report can be used as a retrospective sense check. ";
	put " ";
   put"Thanks,";
   put"CWR automated message";
 run; 
4 REPLIES 4
CamRutherford
Fluorite | Level 6

Sorry, I posted just the email aspect of the code.

 

I create results (sas report) which is what I want attaching in the email.

 

Thanks

Kurt_Bremser
Super User

To attach a file to an email, use the attach= option in the filename email statement.

 

To directly embed HTML output, use the content_type option:

 

filename out email 'receive@domain.com' content_type='HTML';

ods html body=out;

proc print data=sashelp.class;
run;

ods html close;
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Do be aware that email is a really poor medium for distributing data.  You could hit size or other restrictions, you also have multiple copies out there, no control, email is not secure etc.  Use a web portal, with access controls.

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
  • 4 replies
  • 1759 views
  • 0 likes
  • 3 in conversation