The SAS Output Delivery System and reporting techniques

PROC REPORT exports multiple sheet excel file getting Unable to Read File error

Reply
Contributor
Posts: 31

PROC REPORT exports multiple sheet excel file getting Unable to Read File error

I have an EG project where I am doing a PROC REPORT to generate an excel spreadsheet with multiple worksheets within it.  I'm using the PROC REPORT to do this because I have to do color formating based on certain criteria and a bunch of other things, which from what I've read, PROC REPORT is the way to go.  What I'm doing is running through a macro of a file of about 10 different email addresses.  For each email address a specific report gets created based on some criteria.  What's happening is I will get 8 of the 10 to work fine, but the other 2 will generate the file and email it, however, when you go to open it, you get the 'Unable to Read File' error.  Here's the very condensed version of my code...I'm on EG version 7.12 HF2 (7.100.2.3386) (64-bit)

 

FILENAME emailfl "\\my folder location\emailfl.dat";

%macro slsemail(field1, field2, field3, field4, field5, field6);

ods tagsets.ExcelXP path = '\\my folder location\Files'

file = ‘NameOfExcelFile.xls' style=MINIMAL;

ods tagsets.ExcelXP options(sheet_name=’NameOfSheet’

frozen_headers='Yes' frozen_rowheaders='2'

absolute_column_width='2.43,20.70,5,5,5,7,8,5,5,5,5,7,8,5,5,5,5,7,8,5,8,6,6,8,10,5,5,5,5,7,8,5,5,5,5,7,8,5,5,5,5,7,8,5,8,6,6,8,10,5,5,5,5,7,8,5,5,5,5,7,8,5,5,5,5,7,8,5,8,6,6,8,10,5,5,5,5,7,8,5,5,5,5,7,8,5,5,5,5,7,8,5,8,6,6,8,10,5;'

autofit_height='yes');

PROC REPORT DATA=WORK.WorkingFile (WHERE=(Field1 IN("&Field1") ))

                STYLE(REPORT) = [BACKGROUND=WHITE FOREGROUND=BLACK]

                STYLE(COLUMN) = [BACKGROUND=WHITE FOREGROUND=BLACK FONT_SIZE=2]

                STYLE(HEADER) = [BACKGROUND=WHITE FOREGROUND=BLUE FONT_SIZE=2];

                COLUMNS FIELD1 FIELD2, ETC… ;

                DEFINE FIELD1                                                                                   / 'FIELD 1' DISPLAY style={tagattr='format:$#,##0_)'};

                ETC…

                /* Color Alternate rows for easier reading */

                compute FIELD1;

                                RowNum+1;

                                if (mod(RowNum, 2) ne 0)

                                                then call define(_row_, 'style', 'style=[background=#EDEDED]');

                                endcomp;

                /* Color Cells that are negative */

                compute FIELD1;

                                if FIELD1 < 0 and FIELD1 ne '.' THEN

                                                call DEFINE(‘FIEDL1, 'Style', 'STYLE=[BACKGROUND=Red]');

                endcomp;

;RUN;quit;

Super User
Posts: 3,113

Re: PROC REPORT exports multiple sheet excel file getting Unable to Read File error

This is most likely caused by the lack of a CONTENT_TYPE option set for the attachment as shown here:

 

filename mymail email "Somebody@abc.com"
         subject="SAS Test"
         attach=("Test.xls" content_type="application/xls" );
Ask a Question
Discussion stats
  • 1 reply
  • 185 views
  • 0 likes
  • 2 in conversation