<?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 Export to email in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Export-to-email/m-p/851178#M336399</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I create a simple report and want to send it to&amp;nbsp; some people over email .&lt;/P&gt;
&lt;P&gt;I want to attach XLSX file to the email.&lt;/P&gt;
&lt;P&gt;I am using proc export to XLSX file and I see that the file was created and I can open the file .&lt;/P&gt;
&lt;P&gt;The export to email was done well and I see that the email was sent .&lt;/P&gt;
&lt;P&gt;The problem is that I cannot open the XLSX file from the attachment in email.&lt;/P&gt;
&lt;P&gt;Why did it happen?&lt;/P&gt;
&lt;P&gt;Why can't I open the XLSX file from email?&lt;/P&gt;
&lt;P&gt;Here is the message I get&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_0-1672125691276.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78876i1C131E9E8BE43E72/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1672125691276.png" alt="Ronein_0-1672125691276.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Report1 as
select make,
       sum(Invoice) as Total_Invoice format=comma23.,
	   count(*) as nr_rows format=comma23.,
	   calculated Total_Invoice/(select  sum(Invoice) as Total_Invoice  from sashelp.cars Where Origin='Europe') as PCT_Total_Invoice format=percent8.1,
	   calculated nr_rows/(select  count(*) as Total_nr  from sashelp.cars Where Origin='Europe') as PCT_nr_rows format=percent8.1
from sashelp.cars
Where Origin='Europe'
group by make
order by Total_Invoice desc
;
quit;

proc export data=Report1 dbms=xlsx  outfile="/usr/local/SAS/SASUsers/LabRet/UserDir/Report1.XLSX"  replace;
run;

data _null_;
file sendit email
from="&amp;lt;Dave.gdansk@gmail.com&amp;gt;"
to=("&amp;lt;Joe.London@gmail.com&amp;gt;")
cc=("&amp;lt;Yelena.Frucht@gmail.com&amp;gt;","&amp;lt;Bob.Bon@gmail.com&amp;gt;")
subject="Important Document"
importance="High"
attach=("/usr/local/SAS/SASUsers/LabRet/UserDir/Report1.XLSX");
put "Please find attached the report";
put;
put "Thanks!";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 27 Dec 2022 07:29:15 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2022-12-27T07:29:15Z</dc:date>
    <item>
      <title>Export to email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-to-email/m-p/851178#M336399</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I create a simple report and want to send it to&amp;nbsp; some people over email .&lt;/P&gt;
&lt;P&gt;I want to attach XLSX file to the email.&lt;/P&gt;
&lt;P&gt;I am using proc export to XLSX file and I see that the file was created and I can open the file .&lt;/P&gt;
&lt;P&gt;The export to email was done well and I see that the email was sent .&lt;/P&gt;
&lt;P&gt;The problem is that I cannot open the XLSX file from the attachment in email.&lt;/P&gt;
&lt;P&gt;Why did it happen?&lt;/P&gt;
&lt;P&gt;Why can't I open the XLSX file from email?&lt;/P&gt;
&lt;P&gt;Here is the message I get&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_0-1672125691276.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78876i1C131E9E8BE43E72/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1672125691276.png" alt="Ronein_0-1672125691276.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Report1 as
select make,
       sum(Invoice) as Total_Invoice format=comma23.,
	   count(*) as nr_rows format=comma23.,
	   calculated Total_Invoice/(select  sum(Invoice) as Total_Invoice  from sashelp.cars Where Origin='Europe') as PCT_Total_Invoice format=percent8.1,
	   calculated nr_rows/(select  count(*) as Total_nr  from sashelp.cars Where Origin='Europe') as PCT_nr_rows format=percent8.1
from sashelp.cars
Where Origin='Europe'
group by make
order by Total_Invoice desc
;
quit;

proc export data=Report1 dbms=xlsx  outfile="/usr/local/SAS/SASUsers/LabRet/UserDir/Report1.XLSX"  replace;
run;

data _null_;
file sendit email
from="&amp;lt;Dave.gdansk@gmail.com&amp;gt;"
to=("&amp;lt;Joe.London@gmail.com&amp;gt;")
cc=("&amp;lt;Yelena.Frucht@gmail.com&amp;gt;","&amp;lt;Bob.Bon@gmail.com&amp;gt;")
subject="Important Document"
importance="High"
attach=("/usr/local/SAS/SASUsers/LabRet/UserDir/Report1.XLSX");
put "Please find attached the report";
put;
put "Thanks!";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Dec 2022 07:29:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-to-email/m-p/851178#M336399</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-12-27T07:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: Export to email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-to-email/m-p/851179#M336400</link>
      <description>&lt;P&gt;Please post the complete log from all three steps.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 07:28:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-to-email/m-p/851179#M336400</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-27T07:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: Export to email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-to-email/m-p/851180#M336401</link>
      <description>&lt;P&gt;Here is the Log&lt;/P&gt;
&lt;PRE&gt;1                                                          The SAS System                           08:30 Tuesday, December 27, 2022

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Program (6)';
4          %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5          %LET _CLIENTPROJECTPATH='';
6          %LET _CLIENTPROJECTPATHHOST='';
7          %LET _CLIENTPROJECTNAME='';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=PNG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         FILENAME EGSR TEMP;
15         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16             STYLE=HTMLBlue
17             STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HTMLBlue.css")
18             NOGTITLE
19             NOGFOOTNOTE
20             GPATH=&amp;amp;sasworklocation
21             ENCODING=UTF8
22             options(rolap="on")
23         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24         
25         GOPTIONS ACCESSIBLE;
26         proc sql;
27         create table Report1 as
28         select make,
29                sum(Invoice) as Total_Invoice format=comma23.,
30         	   count(*) as nr_rows format=comma23.,
31         	   calculated Total_Invoice/(select  sum(Invoice) as Total_Invoice  from sashelp.cars Where Origin='Europe') as
31       ! PCT_Total_Invoice format=percent8.1,
32         	   calculated nr_rows/(select  count(*) as Total_nr  from sashelp.cars Where Origin='Europe') as PCT_nr_rows
32       ! format=percent8.1
33         from sashelp.cars
34         Where Origin='Europe'
35         group by make
36         order by Total_Invoice desc
37         ;
NOTE: SAS threaded sort was used.
NOTE: Compressing data set WORK.REPORT1 increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: Table WORK.REPORT1 created, with 10 rows and 5 columns.

38         quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      user cpu time       0.02 seconds
      system cpu time     0.00 seconds
      memory              7075.92k
      OS Memory           33712.00k
      Timestamp           12/27/2022 09:30:41 AM
      Step Count                        93  Switch Count  5
      Page Faults                       0
      Page Reclaims                     467
      Page Swaps                        0
      Voluntary Context Switches        67
2                                                          The SAS System                           08:30 Tuesday, December 27, 2022

      Involuntary Context Switches      0
      Block Input Operations            0
      Block Output Operations           0
      

39         
40         proc export data=Report1 dbms=xlsx  outfile="/usr/local/SAS/SASUsers/LabRet/UserDir/Report1.XLSX"  replace;
41         run;

NOTE: The export data set has 10 observations and 5 variables.
NOTE: "/usr/local/SAS/SASUsers/LabRet/UserDir/Report1.XLSX" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
      real time           0.01 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      memory              1673.12k
      OS Memory           29996.00k
      Timestamp           12/27/2022 09:30:41 AM
      Step Count                        94  Switch Count  0
      Page Faults                       0
      Page Reclaims                     210
      Page Swaps                        0
      Voluntary Context Switches        30
      Involuntary Context Switches      0
      Block Input Operations            0
      Block Output Operations           0
      

42         
43         data _null_;
44         file sendit email
45         from="&amp;lt;Bob.Lark@AAA.co.il&amp;gt;"
46         to=("&amp;lt;Bob.Lark@AAA.co.il&amp;gt;")
47         cc=("&amp;lt;Bob.Lark@AAA.co.il&amp;gt;","&amp;lt;Bob.Lark@AAA.co.il&amp;gt;")
48         subject="Important Document"
49         importance="High"
50         attach=("/usr/local/SAS/SASUsers/LabRet/UserDir/udclk79/cars_Report.XLSX" );
51         put "Please find attached the file";
52         put;
53         put "Thanks!";
54         run;

NOTE: The file SENDIT is:
      E-Mail Access Device

Message sent
      To:          "&amp;lt;Bob.Lark@AAA.co.il&amp;gt;"
      Cc:          "&amp;lt;Bob.Lark@AAA.co.il&amp;gt;" "&amp;lt;Bob.Lark@AAA.co.il&amp;gt;"
      Bcc:         
      Subject:     Important Document
      Attachments: ( "/usr/local/SAS/SASUsers/LabRet/UserDir/udclk79/cars_Report.XLSX" ) 
NOTE: 3 records were written to the file SENDIT.
      The minimum record length was 0.
      The maximum record length was 29.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      user cpu time       0.01 seconds
      system cpu time     0.01 seconds
3                                                          The SAS System                           08:30 Tuesday, December 27, 2022

      memory              333.75k
      OS Memory           29348.00k
      Timestamp           12/27/2022 09:30:41 AM
      Step Count                        95  Switch Count  10
      Page Faults                       0
      Page Reclaims                     17
      Page Swaps                        0
      Voluntary Context Switches        86
      Involuntary Context Switches      0
      Block Input Operations            0
      Block Output Operations           0
      

55         
56         
57         GOPTIONS NOACCESSIBLE;
58         %LET _CLIENTTASKLABEL=;
59         %LET _CLIENTPROCESSFLOWNAME=;
60         %LET _CLIENTPROJECTPATH=;
61         %LET _CLIENTPROJECTPATHHOST=;
62         %LET _CLIENTPROJECTNAME=;
63         %LET _SASPROGRAMFILE=;
64         %LET _SASPROGRAMFILEHOST=;
65         
66         ;*';*";*/;quit;run;
67         ODS _ALL_ CLOSE;
68         
69         
70         QUIT; RUN;
71         
&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Dec 2022 07:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-to-email/m-p/851180#M336401</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-12-27T07:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: Export to email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-to-email/m-p/851181#M336402</link>
      <description>&lt;P&gt;I found the solution:)&lt;/P&gt;
&lt;P&gt;Need to add statement&amp;nbsp;&lt;/P&gt;
&lt;P&gt;content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")&lt;/P&gt;
&lt;P&gt;The question is why this statement is essential?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Report1 as
select make,
       sum(Invoice) as Total_Invoice format=comma23.,
	   count(*) as nr_rows format=comma23.,
	   calculated Total_Invoice/(select  sum(Invoice) as Total_Invoice  from sashelp.cars Where Origin='Europe') as PCT_Total_Invoice format=percent8.1,
	   calculated nr_rows/(select  count(*) as Total_nr  from sashelp.cars Where Origin='Europe') as PCT_nr_rows format=percent8.1
from sashelp.cars
Where Origin='Europe'
group by make
order by Total_Invoice desc
;
quit;

proc export data=Report1 dbms=xlsx  outfile="/usr/local/SAS/SASUsers/LabRet/UserDir/Report1.XLSX"  replace;
run;

data _null_;
file sendit email
from="&amp;lt;Bob.Dave@gmail.com&amp;gt;"
to=("&amp;lt;Bob.Dave@gmail.com&amp;gt;")
cc=("&amp;lt;Bob.Dave@gmail.com&amp;gt;","&amp;lt;Bob.Dave@gmail.com&amp;gt;")
subject="Important Document"
importance="High"
attach=("/usr/local/SAS/SASUsers/LabRet/UserDir/udclk79/cars_Report.XLSX"
content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
put "Please find attached the file";
put;
put "Thanks!";
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 07:47:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-to-email/m-p/851181#M336402</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-12-27T07:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Export to email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-to-email/m-p/851191#M336405</link>
      <description>&lt;P&gt;Normally the OS will try to choose an appropriate application to open an attachment based on the extension. However an XLSX spreadsheet is actually a compressed folder of XML-based files so the OS has difficulty figuring out how to handle the attachment, hence the content type identification.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 08:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-to-email/m-p/851191#M336405</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-12-27T08:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Export to email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-to-email/m-p/851233#M336427</link>
      <description>&lt;P&gt;Did you try (before making the change that made it work) to save the attachment manually and then open it from within Excel?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 12:17:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-to-email/m-p/851233#M336427</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-27T12:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Export to email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-to-email/m-p/851246#M336431</link>
      <description>I didn't try it but anyway people who recieve the email should be able to open the xlsx file via email</description>
      <pubDate>Tue, 27 Dec 2022 14:04:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-to-email/m-p/851246#M336431</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-12-27T14:04:40Z</dc:date>
    </item>
  </channel>
</rss>

