BookmarkSubscribeRSS Feed
LisaSAS
Obsidian | Level 7

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;

1 REPLY 1
SASKiwi
PROC Star

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" );

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 765 views
  • 0 likes
  • 2 in conversation