Hello, I have some code that successfully includes table values in an email using the "Proc Print" procedure. Now I would like to add an .xls attachment in the same email. When I include the "ATTACH" code I receive an error stating the code is out of order. My email still sends although without the attachment. Suspecting I need to add more ODS statements.
Here is my code... Thanks!
FILENAME mail EMAIL TO=("xxx.com" )
FROM = "xxx.com"
SUBJECT="xxx" CONTENT_TYPE="text/html";
ODS LISTING CLOSE;
ODS HTML BODY=mail;
FILENAME PRINT;
PUT "Good Morning, Attached is .... Please let me know if you have any questions"
ATTACH = ( "xxx..xls" content_type="application/excel");
PROC PRINT DATA=Exclusion_Summ NOOBS;
RUN;
PROC PRINT DATA=Report_Summ NOOBS;
RUN;
PROC PRINT DATA=Output_Summ NOOBS;
RUN;
ODS HTML CLOSE;
ODS LISTING;
Thank you so much Chris! Works great, here is the code
FILENAME mail EMAIL TO=("xxx.com" )
FROM = "xxx.com"
SUBJECT="xxx" CONTENT_TYPE="text/html";
ATTACH = ( "/xx/xx..xls" content_type="application/excel");
ODS LISTING CLOSE;
ODS HTML BODY=mail;
data _null_;
file MAIL;
PUT "Good Morning, Attached is .... Please let me know if you have any questions";
RUN;
PUT "Good Morning, Attached is .... Please let me know if you have any questions"
ATTACH = ( "xxx..xls" content_type="application/excel");
PROC PRINT DATA=Exclusion_Summ NOOBS;
RUN;
PROC PRINT DATA=Report_Summ NOOBS;
RUN;
PROC PRINT DATA=Output_Summ NOOBS;
RUN;
ODS HTML CLOSE;
ODS LISTING;
1. The PUT statement must be inside a data step. Add:
data _null_;
file MAIL;
before the PUT statement.
2. ATTACH is an option for the FILENAME statement.
Thank you so much Chris! Works great, here is the code
FILENAME mail EMAIL TO=("xxx.com" )
FROM = "xxx.com"
SUBJECT="xxx" CONTENT_TYPE="text/html";
ATTACH = ( "/xx/xx..xls" content_type="application/excel");
ODS LISTING CLOSE;
ODS HTML BODY=mail;
data _null_;
file MAIL;
PUT "Good Morning, Attached is .... Please let me know if you have any questions";
RUN;
PUT "Good Morning, Attached is .... Please let me know if you have any questions"
ATTACH = ( "xxx..xls" content_type="application/excel");
PROC PRINT DATA=Exclusion_Summ NOOBS;
RUN;
PROC PRINT DATA=Report_Summ NOOBS;
RUN;
PROC PRINT DATA=Output_Summ NOOBS;
RUN;
ODS HTML CLOSE;
ODS LISTING;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.