BookmarkSubscribeRSS Feed
LMW5
Calcite | Level 5

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.

6 REPLIES 6
LMW5
Calcite | Level 5

***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;

LMW5
Calcite | Level 5

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."

Kurt_Bremser
Super User

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.

LMW5
Calcite | Level 5

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

LMW5
Calcite | Level 5

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

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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1856 views
  • 0 likes
  • 2 in conversation