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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 2237 views
  • 0 likes
  • 3 in conversation