<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SAS-send email and attach multiple files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-send-email-and-attach-multiple-files/m-p/930774#M366188</link>
    <description>&lt;P&gt;As almost always, Maxim 1.&lt;/P&gt;
&lt;P&gt;From the documentation of&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsglobal/n0ig2krarrz6vtn1aw9zzvtez4qo.htm" target="_blank" rel="noopener"&gt;FILENAME Statement, EMAIL method&lt;/A&gt;:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;H4 class="xisDoc-argument"&gt;ATTACH='&lt;EM class="xisDoc-userSuppliedValue"&gt;filename.ext&lt;/EM&gt;' | ATTACH= ('&lt;EM class="xisDoc-userSuppliedValue"&gt;filename.ext&lt;/EM&gt;'&lt;EM class="xisDoc-userSuppliedValue"&gt;attachment-options&lt;/EM&gt;)&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies the physical name of the file or files to be attached to the message and any options to modify attachment specifications. The physical name is the name that is recognized by the operating environment. Enclose the physical name in quotation marks. &lt;STRONG&gt;To attach more than one file, enclose the group of files in parentheses, enclose each file in quotation marks, and separate each with a space.&lt;/STRONG&gt; Here are examples:&lt;/P&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;For the raw data, use PROC EXPORT to create the second Excel file.&lt;/P&gt;
&lt;/DIV&gt;</description>
    <pubDate>Tue, 04 Jun 2024 08:12:54 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2024-06-04T08:12:54Z</dc:date>
    <item>
      <title>SAS-send email and attach multiple files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-send-email-and-attach-multiple-files/m-p/930766#M366181</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I want to send email from SAS and in the email will have:&lt;/P&gt;
&lt;P&gt;1-Attach XLSX file with summary data (summary data set)&lt;/P&gt;
&lt;P&gt;2-Attach XLSX file with raw data (sashelp.cars data set)&lt;/P&gt;
&lt;P&gt;3-In email Body print&amp;nbsp;summary data (summary data set)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the code below I attach one file (summary data)&lt;/P&gt;
&lt;P&gt;My question-What is the way to attach also&amp;nbsp;raw data (sashelp.cars data set)?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql;
create table summary as
select type,
       sum(invoice) as sum_invoice
from  sashelp.cars
group by type
;
quit;


/**CREATE EXCEL FILE***/
ODS EXCEL FILE="/usr/local/SAS/SASUsers/LabRet/UserDir/udclk79/summary_Report_Cars.xlsx" style=htmlblue options(
frozen_headers="ON" 
/*autofilter = "1-17" */
row_heights="30,13,13,13,13,13,13"
flow = "header, data" 
absolute_column_width = "18,20,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10" 
sheet_name = "Cars"
) ;
title;
footnote;
title1 'Smmary of cars';
proc print data=summary  noobs;
Run;
ods excel close;

FILENAME mail EMAIL 
TO=("Ron.gdansk@gmail.com")
FROM='SAS  &amp;lt;Ron.Einstein@BankLeumi.co.il&amp;gt;'
SUBJECT="Cars"
encoding='utf-8'   
CONTENT_TYPE="text/html" 
encoding="utf-8"
attach=("/usr/local/SAS/SASUsers/LabRet/UserDir/udclk79/summary_Report_Cars.xlsx" content_type="excel");
/*******Here I want to attach also another data set called sashelp.cars****/
ODS LISTING CLOSE;
ODS HTML BODY=mail;
/*** EMAIL BODY TEXT**********/
title;
footnote;
title  JUSTIFY=center color="purple" height=25pt bold italic underlin=1  'Cars';
proc report data=summary nowd;
column _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 06:25:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-send-email-and-attach-multiple-files/m-p/930766#M366181</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-06-04T06:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: SAS-send email and attach multiple files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-send-email-and-attach-multiple-files/m-p/930774#M366188</link>
      <description>&lt;P&gt;As almost always, Maxim 1.&lt;/P&gt;
&lt;P&gt;From the documentation of&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsglobal/n0ig2krarrz6vtn1aw9zzvtez4qo.htm" target="_blank" rel="noopener"&gt;FILENAME Statement, EMAIL method&lt;/A&gt;:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;H4 class="xisDoc-argument"&gt;ATTACH='&lt;EM class="xisDoc-userSuppliedValue"&gt;filename.ext&lt;/EM&gt;' | ATTACH= ('&lt;EM class="xisDoc-userSuppliedValue"&gt;filename.ext&lt;/EM&gt;'&lt;EM class="xisDoc-userSuppliedValue"&gt;attachment-options&lt;/EM&gt;)&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies the physical name of the file or files to be attached to the message and any options to modify attachment specifications. The physical name is the name that is recognized by the operating environment. Enclose the physical name in quotation marks. &lt;STRONG&gt;To attach more than one file, enclose the group of files in parentheses, enclose each file in quotation marks, and separate each with a space.&lt;/STRONG&gt; Here are examples:&lt;/P&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;For the raw data, use PROC EXPORT to create the second Excel file.&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 04 Jun 2024 08:12:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-send-email-and-attach-multiple-files/m-p/930774#M366188</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-06-04T08:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS-send email and attach multiple files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-send-email-and-attach-multiple-files/m-p/930775#M366189</link>
      <description>&lt;P&gt;Hi, I tried attaching using the filename statement and could not get it to work despite specifying content_type as&amp;nbsp;&lt;SPAN&gt;application/x-sas-data.&amp;nbsp;&lt;BR /&gt;I received the following error:&amp;nbsp;&lt;A href="https://support.sas.com/kb/39/996.html" target="_blank"&gt;39996 - "ERROR: An attachment record was truncated" when sending files as email attachments&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;ERROR: An attachment record was truncated. The attachment LRECL is too small.&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME mail EMAIL 
TO=("johndoe@email.com")
FROM=("johndoe@email.com")
SUBJECT="Cars"
encoding='utf-8'
CONTENT_TYPE="text/html"
encoding="utf-8"
lrecl=32767
attach=("%sysfunc(pathname(work))/cars.sas7bdat" content_type="application/x-sas-data");
/*******Here I want to attach also another data set called sashelp.cars****/

Data _null_;
	file mail;
	put "Testing";
	put "Testing";
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;Though, I was wondering if you could try using the mailx command in conjunction with %sysexec macro statement instead?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 08:36:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-send-email-and-attach-multiple-files/m-p/930775#M366189</guid>
      <dc:creator>Mazi</dc:creator>
      <dc:date>2024-06-04T08:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: SAS-send email and attach multiple files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-send-email-and-attach-multiple-files/m-p/930793#M366201</link>
      <description>&lt;P&gt;I don't have an environment where I could try it myself but just looking at your code, the referenced usage note and doing some further Internet research I can't see anything wrong in your code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I couldn't find any confirmed solution anywhere how to send a single .sas7bdat as email attachment.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe what would add value to the forums here: Contact SAS Tech Support directly and then post the final answer/resolution back here and mark it as solution/answer as provided by SAS Tech Support.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 12:09:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-send-email-and-attach-multiple-files/m-p/930793#M366201</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-06-04T12:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS-send email and attach multiple files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-send-email-and-attach-multiple-files/m-p/930798#M366204</link>
      <description>&lt;P&gt;Try SAS7BDAT:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME mail EMAIL 
TO=("xxx@email.com")
FROM=("yyyy@email.com")
SUBJECT="Cars"
encoding='utf-8'
CONTENT_TYPE="text/html"
encoding="utf-8"
attach=(
"%sysfunc(pathname(work))/cars.sas7bdat" 
content_type="application/SAS7BDAT" /* &amp;lt;-----------------------*/
)
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 12:25:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-send-email-and-attach-multiple-files/m-p/930798#M366204</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-06-04T12:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: SAS-send email and attach multiple files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-send-email-and-attach-multiple-files/m-p/930819#M366210</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file = "~/test.xlsx";
	proc print data=sashelp.cars;
	run;
ods excel close;

proc copy in=sashelp out=work;
	select cars;
run;

FILENAME mail EMAIL 
TO=("xxx@email.com")
FROM=("xxx@email.com")
SUBJECT="Cars"
encoding='utf-8'
CONTENT_TYPE="text/html"
encoding="utf-8"
attach=(
"%sysfunc(pathname(work))/cars.sas7bdat" 
content_type="application/SAS7BDAT" "~/test.xlsx" content_type="excel"
)
;

data _null_;
	file mail;
	Put "Testing";
	Put "Testing";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This seems to have worked for me.&amp;nbsp;&lt;BR /&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;for the suggestion.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 14:57:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-send-email-and-attach-multiple-files/m-p/930819#M366210</guid>
      <dc:creator>Mazi</dc:creator>
      <dc:date>2024-06-04T14:57:16Z</dc:date>
    </item>
  </channel>
</rss>

