<?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 Error in attachment filename code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-in-attachment-filename-code/m-p/748741#M235170</link>
    <description>&lt;P&gt;I am attempting to get a file to email a message and an attachment. The outfile was defined as:&lt;/P&gt;
&lt;PRE&gt;/f1/file09/sascode/reporting/dev/output
&lt;/PRE&gt;
&lt;P&gt;The report out information was defined as follows:&lt;/P&gt;
&lt;PRE&gt;%Let ReportName=Capital99_Report_;
%let ReportOut=&amp;amp;ReportName.&amp;amp;today;
%put REPORTNAME=&amp;amp;ReportName;
%put REPORTOUT=&amp;amp;ReportOut;

proc export
data=final
outfile="&amp;amp;outdir/&amp;amp;ReportOut."
label
dbms=xlsx
replace
;
run;

The output writes successfully as follows:
NOTE: The export data set has 104421 observations and 31 variables.
NOTE: "/f1/file09/sascode/reporting/dev/output/Capital99_Report_20210617.xlsx" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):


filename MI_email
  email
  to=("myemail@bank1.com") 
  subject="Capital99 Report &amp;amp;today." 
  attach = "&amp;amp;outdir/&amp;amp;ReportOut."
;

data _null_; 
FILE MI_email; 
  
PUT "Capital99 Report_&amp;amp;today. is now ENCLOSED in this email.  ";

run;  

However I get this error when I run the filename code above
NOTE: The file MI_EMAIL is:
      E-Mail Access Device

ERROR: Error opening attachment file /f1/file09/sascode/reporting/dev/output/Capital99_Report_20210617.
ERROR: Physical file does not exist, /f1/file09/sascode/reporting/dev/output/Capital99_Report_20210617.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


&lt;/PRE&gt;
&lt;P&gt;Is it because it is not recognizing the .xlsx extention?? I cannot figure out why this happens because the file clearly writes to the /f1/file09/sascode/reporting/dev/output drive&lt;/P&gt;</description>
    <pubDate>Thu, 17 Jun 2021 19:04:26 GMT</pubDate>
    <dc:creator>Q1983</dc:creator>
    <dc:date>2021-06-17T19:04:26Z</dc:date>
    <item>
      <title>Error in attachment filename code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-attachment-filename-code/m-p/748741#M235170</link>
      <description>&lt;P&gt;I am attempting to get a file to email a message and an attachment. The outfile was defined as:&lt;/P&gt;
&lt;PRE&gt;/f1/file09/sascode/reporting/dev/output
&lt;/PRE&gt;
&lt;P&gt;The report out information was defined as follows:&lt;/P&gt;
&lt;PRE&gt;%Let ReportName=Capital99_Report_;
%let ReportOut=&amp;amp;ReportName.&amp;amp;today;
%put REPORTNAME=&amp;amp;ReportName;
%put REPORTOUT=&amp;amp;ReportOut;

proc export
data=final
outfile="&amp;amp;outdir/&amp;amp;ReportOut."
label
dbms=xlsx
replace
;
run;

The output writes successfully as follows:
NOTE: The export data set has 104421 observations and 31 variables.
NOTE: "/f1/file09/sascode/reporting/dev/output/Capital99_Report_20210617.xlsx" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):


filename MI_email
  email
  to=("myemail@bank1.com") 
  subject="Capital99 Report &amp;amp;today." 
  attach = "&amp;amp;outdir/&amp;amp;ReportOut."
;

data _null_; 
FILE MI_email; 
  
PUT "Capital99 Report_&amp;amp;today. is now ENCLOSED in this email.  ";

run;  

However I get this error when I run the filename code above
NOTE: The file MI_EMAIL is:
      E-Mail Access Device

ERROR: Error opening attachment file /f1/file09/sascode/reporting/dev/output/Capital99_Report_20210617.
ERROR: Physical file does not exist, /f1/file09/sascode/reporting/dev/output/Capital99_Report_20210617.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


&lt;/PRE&gt;
&lt;P&gt;Is it because it is not recognizing the .xlsx extention?? I cannot figure out why this happens because the file clearly writes to the /f1/file09/sascode/reporting/dev/output drive&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 19:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-attachment-filename-code/m-p/748741#M235170</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2021-06-17T19:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Error in attachment filename code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-attachment-filename-code/m-p/748744#M235173</link>
      <description>&lt;P&gt;Does your attachment file name include the file extension? It appears not to. So the code is looking for a file without any extension.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to attach some file named "thisfile.txt" you must use something that resolves to "thisfile.txt", not "thisfile".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 19:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-attachment-filename-code/m-p/748744#M235173</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-17T19:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Error in attachment filename code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-attachment-filename-code/m-p/748745#M235174</link>
      <description>&lt;P&gt;Code blocks are for code, put your text in the body of the message. The point of these separators is to make the post more legible and easier to understand, putting everything in one box entirely defeats that purpose. &lt;BR /&gt;&lt;BR /&gt;And yes, you're missing the extension so the file is not attached. What would happen if you have multiple files with the same name and different extensions? &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Change attach to : &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;attach = "&amp;amp;outdir/&amp;amp;ReportOut..xlsx"&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Jun 2021 19:06:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-attachment-filename-code/m-p/748745#M235174</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-17T19:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Error in attachment filename code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-attachment-filename-code/m-p/748758#M235181</link>
      <description>&lt;P&gt;For clarity, use this in the PROC EXPORT statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;outfile="&amp;amp;outdir/&amp;amp;ReportOut..xlsx"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and later&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;attach = "&amp;amp;outdir/&amp;amp;ReportOut..xlsx"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in the FILENAME.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems that the EXPORT procedure adds a filename extension on its own if none is supplied.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 20:04:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-attachment-filename-code/m-p/748758#M235181</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-17T20:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: Error in attachment filename code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-attachment-filename-code/m-p/748807#M235217</link>
      <description>This works.  I am even able to get the attachment to show in an email.  When I try and open the excel I get a corrupt email message.  I believe its because the file has 104,000 records although xlsx is supposed to handle this size.  I changed the dbms from xlsx to the sequence below:&lt;BR /&gt;dbms=EXCELCS&lt;BR /&gt;replace&lt;BR /&gt;;&lt;BR /&gt;SERVER='saspcff'; &lt;BR /&gt;I get the following error&lt;BR /&gt;ERROR: CLI error trying to establish connection: [Microsoft][ODBC Excel Driver] '(unknown)' is not a valid path. Make sure that the path name is &lt;BR /&gt;       spelled correctly and that you are connected to the server on which the file resides.&lt;BR /&gt;ERROR: Error in the LIBNAME statement.&lt;BR /&gt;ERROR: Connection Failed.  See log for details.&lt;BR /&gt;I suspect the server name SERVER='saspcff';  Is there a way to use xlsb without reference to a server name or is there a script in sas that would provide the current server name, assuming that saspcff is incorrect??&lt;BR /&gt;</description>
      <pubDate>Fri, 18 Jun 2021 01:34:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-attachment-filename-code/m-p/748807#M235217</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2021-06-18T01:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: Error in attachment filename code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-attachment-filename-code/m-p/748823#M235228</link>
      <description>&lt;P&gt;Download the Excel file directly from the server, and check if it opens outside of an email. Also do a cross-check with LibreOffice.&lt;/P&gt;
&lt;P&gt;It may be that the size of the attachment is limited by constraints imposed on the email.&lt;/P&gt;
&lt;P&gt;Your ERROR now happens in a LIBNAME, not in PROC EXPORT.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 04:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-attachment-filename-code/m-p/748823#M235228</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-18T04:16:45Z</dc:date>
    </item>
  </channel>
</rss>

