Programming the statistical procedures from SAS

issues with emailing excel files, which are generated by ods excel

Reply
Occasional Contributor
Posts: 5

issues with emailing excel files, which are generated by ods excel

After generating excel files with ods excel and proc report, I used SAS email macro to send out a email with excel files attached. But I couldn't open attached excel files. If I emailed them manually, I can open them.

Super User
Posts: 10,278

Re: issues with emailing excel files, which are generated by ods excel

Please show your code and log.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 5

Re: issues with emailing excel files, which are generated by ods excel

Posted in reply to KurtBremser

***to generate excel file***;

ods excel file="/pro/temp/list.xlsx" style=f304temp startpage=yes bodytitle;

proc report data=list_csv nowd split='*' headline headskip
style(header)=[font_size=10pt font_weight=bold]
style(column)=[just=center cellwidth=0.7in];

column ("Center" ccn)("PID" pid) ("Code" ac);

define ccn / display " " style=[just=left cellwidth=1.7in];
define pid/ display " ";
define ac/ display " " style=[cellwidth=0.6in];

run;
ods excel close;

 

*** to email out the excel file***;

%macro mail7 (dy=2);

%if &ndy = &dy %then %do;

 

data _null_;
file mailout;
put " ";
put " ";
filename mailout email 
from=('shes@yahoo.com')
to=('par@yahoo.com')
 subject="List of Patients &tdate"
attach=("/pro/94/list_&mdy..xlsx")
;
run ;
%end;
%mend mail7;

Occasional Contributor
Posts: 5

Re: issues with emailing excel files, which are generated by ods excel

no error info in log file, but When I tried to open attached file, it said "we found a problem with some content in the excel file."

Super User
Posts: 10,278

Re: issues with emailing excel files, which are generated by ods excel

Are you sure it happens during the email transfer? It's hard to imagine how sending it in the email could slightly damage a zip-compressed file without completely trashing it.

 

I'd rather suspect that something in the SAS data messes with the XML structure of the xlsx file.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 5

Re: issues with emailing excel files, which are generated by ods excel

Type: specifies the content type for the message body. If you do not specify any content type, SAS tries to determine the correct content type. You must enclose the value in quotation marks type='content/type' The default value of this parameter is ‘text/plain’.

 

Can anyone tell me what is the list of "content/type"? thanks

Occasional Contributor
Posts: 5

Re: issues with emailing excel files, which are generated by ods excel

The problem has been solved. Just need to point out content type:

attach=("/xxxx/xxxx/xxxxxxxxx.xlsx"  content_type="application/xlsx")

Ask a Question
Discussion stats
  • 6 replies
  • 128 views
  • 0 likes
  • 2 in conversation