BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
bijayadhikar
Quartz | Level 8
I generated a PowerPoint presentation (.pptx) using the ODS PowerPoint destination and properly closed it with:
ods powerpoint close;
 
I use SAS 9.4 with EG 8.5. The PPTX file is created successfully and opens normally from Windows Explorer. The file size on disk is approximately 1.5 MB (1,495 KB).
However, when I send the same PPTX as an email attachment using the SAS Email engine, the recipient receives a much smaller file (approximately 514 bytes). When they try to open it, PowerPoint prompts to repair the file and then fails to open it.
There are no errors in the SAS log.
Troubleshooting completed:
  • SAS can locate the file (FILEEXIST=1).
  • SAS can read the file and reports the correct size (~1.5 MB).
  • The PPTX opens normally from Windows Explorer.
  • The network path is valid and accessible.
  • PDF files attached from the same folder and using the same email code work correctly.
  • FCOPY successfully copies the PPTX to a local WORK directory (RC=0).
Based on these tests, it appears the issue may be related to how the SAS Email engine is attaching .pptx files rather than a problem with the PowerPoint file itself.
Has anyone experienced a similar issue with .pptx attachments being truncated or corrupted when sent through the SAS Email engine? If so, were there any recommended workarounds or configuration changes?
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

@bijayadhikar wrote:
Sorry for typo. PPTX was not copied as text.

Why do you think that?

 

Try being specific in how you want SAS to read and write the files when copying.

filename src "&pptpath" recfm=f lrecl=512;
filename dst "&pptlocal" recfm=f lrecl=512;

Also make sure to tell the email process what type of file it is attaching, this will help the recipient know what application to use to open the file.  It will also help with email filters. 

filename mymail email
  to = "my.email@com"
  subject = "Monthly Performance Deck"
  attach = ("&pptlocal" content_type="application/pptx")
;

View solution in original post

11 REPLIES 11
Quentin
Super User

You might try something like zipping the pptx file before emailing it, if you suspect it's getting corrupted by SAS or your mail server.   Maybe that's a silly idea, since pptx is literally a zip file.  

 

You could try changing the extension on the .pptx to something neutral like .txt in case your email system has blocker on sending .pptx files.

 

If you have IT support, you might want to check with them to see if they can see if the mail server logs say anything interesting.

 

I guess it's possible SAS somehow munged the file during upload.  If you do a simple .pptx with just one slide from PROC PRINT, does the email work?

The Boston Area SAS Users Group is hosting free webinars!

Register now at https://www.basug.org/events.
SASKiwi
PROC Star

The usual way to add an email attachment that is for a specific application is to use the CONTENT_TYPE option. Try something like this:

filename mymail email "[email protected]"
         subject="PPT Test"
         attach=("MyPPT.pptx"  content_type="application/pptx");

data _null_;
   file mymail;
   put 'Hi Me,';
   put 'This is a test.';
run;
Tom
Super User Tom
Super User

If you copy a BINARY file as TEXT it can become corrupted.

 

Please share the code you used for FCOPY , in particular how you defined the two FILEREFs used.  Make sure your are not using RECFM=V. Using RECFM=F is best, RECFM=N might work also.

bijayadhikar
Quartz | Level 8
ods powerpoint close;
ods listing;
 
filename mymail email
to = "my.email@com"
subject = "PPTX Attachment Test"
attach = "&pptpath";
 
data _null_;
file mymail;
 
put "Hello,";
put "Please find the attached PowerPoint presentation for your review.";
put "Best regards,";
put "CD Team";
run;

 

Result
  • Email sent successfully
  • PPTX attachment received
  • Attachment size approximately 514-579 bytes
  • PowerPoint attempts repair and then fails to open
FCOPY Test
%let pptlocal=%sysfunc(pathname(work))\COPIED_TEST_Report.pptx;
 
filename src "&pptpath";
filename dst "&pptlocal";
 
data _null_;
rc=fcopy('src','dst');
put rc=;
run;

Log rc=0
 

Verify Local Copy Exists

filename test "&pptlocal";
 
data _null_;
fid = fopen('test');
 
if fid > 0 then do;
put 'EXISTS=1';
rc = fclose(fid);
end;
else put 'EXISTS=0';
run;

Log:  EXISTS=1
 
Attach Local Copy Instead
filename mymail email
to = "my.email@com"
subject = "Monthly Performance Deck"
attach = "&pptlocal";
 
data _null_;
file mymail;
put "Hello,";
put "Please find the attached PowerPoint presentation.";
put "Best regards,";
put "CD Team";
run;

 

Additional Validation

I verified that SAS can read the original PPTX and reports the expected file size.
filename chk "&pptpath";
 
data _null_;
fid=fopen('chk');
 
if fid then do;
size=finfo(fid,'File Size (bytes)');
put size=;
rc=fclose(fid);
end;
run;

Log: size=1456840
The original PPTX also opens normally from Windows Explorer.
No RECFM= option was specified.
No RECFM= option was specified.
Therefore the filerefs are using the default host settings.
I am not using:
recfm=v
recfm=f
recfm=n

 

PPTX was copied as text.
bijayadhikar
Quartz | Level 8
Sorry for typo. PPTX was not copied as text.
bijayadhikar
Quartz | Level 8
Another test: The file that SAS copied likely not a valid PPTX copy. Original PPTX = 1,456,840 bytes
Copied PPTX = 109 bytes
ZIP file = 146 bytes. This size which is not remotely close to a valid PPTX.

Any thoughts appreciated.
SASKiwi
PROC Star

This worked fine for me. I created a test PPTX in Powerpoint, saved it to a SAS server folder, ran the below program. I just double-clicked on the email attachment and the Powerpoint opened as I expected:

filename mymail email "[email protected]"
         subject="PPTX Test"
         attach=("TestPPTX.pptx"  content_type="application/pptx" 
         );

data _null_;
   file mymail;
   put 'Hi Me,';
   put 'This is a test.';
run;

This is the test email:

SASKiwi_0-1786581079707.png

 

Tom
Super User Tom
Super User

@bijayadhikar wrote:
Sorry for typo. PPTX was not copied as text.

Why do you think that?

 

Try being specific in how you want SAS to read and write the files when copying.

filename src "&pptpath" recfm=f lrecl=512;
filename dst "&pptlocal" recfm=f lrecl=512;

Also make sure to tell the email process what type of file it is attaching, this will help the recipient know what application to use to open the file.  It will also help with email filters. 

filename mymail email
  to = "my.email@com"
  subject = "Monthly Performance Deck"
  attach = ("&pptlocal" content_type="application/pptx")
;
bijayadhikar
Quartz | Level 8

Thank you very much TOM. The FCOPY with RECFM=f did work; however PowerPoint repair warning keeps coming. When I use RECFM=n, the warning is no longer coming.  Here is my script that worked well.

 

%put &=pptpath;

/*Window explorer: FILE SIZE=1495 KB*/


%let pptlocal=....\COPIED_TEST_Report.pptx;

filename src "&pptpath" recfm=f lrecl=512;
filename dst "&pptlocal" recfm=f lrecl=512;

/* Copy PPTX */

data _null_;
rc=fcopy('src','dst');
put "FCOPY RC=" rc;
run;

/*Log: FCOPY RC=0*/

/*verify copied file*/
filename chk "&pptlocal";

data _null_;
fid=fopen('chk');

if fid > 0 then do;
size=finfo(fid,'File Size (bytes)');
put 'COPIED FILE SIZE=' size;
rc=fclose(fid);
end;
else put 'FILE COULD NOT BE OPENED';
run;

/*Log: COPIED FILE SIZE=1495 KB*/

filename chk "&pptlocal";


filename mymail email
to = "my.email@com"
subject = "Monthly Performance Deck"

attach = (
"&pptlocal"
content_type="application/pptx"
)
;

/* Write the email body */
data _null_;
file mymail;
put "Hello,";
put ;
put "Please find the attached PowerPoint presentation for your review.";
put ;
put "Best regards,";
put "CD Team";
run;


Conclusion:

Using FCOPY with recfm=f:

filename src "&pptpath" recfm=f lrecl=512;
filename dst "&pptlocal" recfm=f lrecl=512;

I successfully produced a full-sized PPTX copy (1,495 KB). The emailed attachment is no longer truncated and opens successfully after repair. The original issue of receiving a 514–579 byte attachment appears resolved. The remaining issue is that PowerPoint still displays a repair prompt before opening the emailed PPTX.

Question
Given that:
The original and copied PPTX files are both math 1,495 KB
The copied file opens normally outside Outlook
The emailed attachment is no longer truncated
PowerPoint still performs a repair when opening the attachment
It did work nicely except repair warning

 

However, I use RECFM=N option no longer receives warning.

filename src "&pptpath" recfm=n lrecl=512;
filename dst "&pptlocal" recfm=n lrecl=512;

Ksharp
Super User

1) Try this code

filename src "&pptpath";
filename dst "&pptlocal";
 ------->
filename src "&pptpath"  recfm=n;
filename dst "&pptlocal"  recfm=n;
 

https://blogs.sas.com/content/sasdummy/2013/09/17/copy-file-macro/

 

2) Try RENAME() function:

data _null_;
rc=rename("c:\old\x.pptx","c:\new\x.pptx",'file');
put rc= ;
run;
bijayadhikar
Quartz | Level 8

Thank you Ksharp. Appreciated for help., I did not try renaming but using recfm=n  stopped PowerPoint repair warning. 

filename src "&pptpath"  recfm=n;
filename dst "&pptlocal"  recfm=n;

 

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch 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
  • 11 replies
  • 180 views
  • 4 likes
  • 5 in conversation