I'm following a (relatively old) SAS Institute paper for outputting fancy formatted tables to Excel sheets, specifically Example 3 (page 5), just the first sheet.
ods escapechar = "^"; ods excel file = "C:\sas_test1.xlsx" options(sheet_name = "My Fancy Sheet"); ods text = "New Report1"; proc report data = test1; column var1 var2 var3 var4 var5 var6; run; ods excel close;
SAS threw an error when I inserted the style block from the tutorial, so I dropped that for the time being.
Once I go to open the file, though, I get an error from Excel, which then generates an XML log detailing the issue:
<summary>Errors were detected in file 'C:\sas_test1.xlsx'</summary>
<removedRecords><removedRecord>Removed Records: Worksheet properties from /xl/worksheets/sheet1.xml part</removedRecord></removedRecords>
</recoveryLog>
Has anyone else encountered this or would be able to help me understand what I'm doing incorrectly?
Thanks!
If you're using an interactive SAS session like Enterprise Guide, Display Manager ("PC SAS"), etc., sometimes it's best to close the session and re-open it. A close and re-open will clear hard to reset things, things which might generate that PNG message (even though you're not using any images).
Jim
If what @RyanJB is experiencing is like what I have experienced, then the SAS log will show nothing. From SAS' perspective, everything went well. It's just that when you try to open the spreadsheet in Excel, it won't open. At least that's what I've experienced on numerous occasions. I've had to do a bit of SAS template coding to make things work. With ExcelXP, the infamous one was character strings containing all numeric digits that were longer than 32 in length. SAS, even if they had a $ definition, would try to render them as numbers, and Excel would balk. I had to edit the template to say if it's longer than 32 then handle it as character, period. It worked fine after I modded the template. Template code is funky. It's basically another language. It's SAS like, but it's not SAS.
Jim
Sorry, my mind was focused on the Excel problem rather than the SAS problem. That said, the log I initially posted (edited below) does show a warning.
Beyond that, what @jimbarbour said is true - just standard end-of-log output. Pasted below:
NOTE: Writing HTML5(EGHTML) Body file: EGHTML
27
28 ods excel file = "C:\sas_test1.xlsx";
WARNING: Unsupported device 'SVG' for EXCEL destination. Using default device 'PNG'.
29 *ods text = "New Report1";
30 proc report data = test1;
31 column var1 var2 var3 var4 var5 var6;
32 run;
NOTE: There were 192 observations read from the data set WORK.TEST1. NOTE: PROCEDURE REPORT used (Total process time): real time 0.51 seconds cpu time 0.45 seconds 33 ods excel close; NOTE: Writing EXCEL file: C:\sas_test1.xlsx 34 35 %LET _CLIENTTASKLABEL=; 36 %LET _CLIENTPROCESSFLOWNAME=; 37 %LET _CLIENTPROJECTPATH=; 38 %LET _CLIENTPROJECTPATHHOST=; 39 %LET _CLIENTPROJECTNAME=; 40 %LET _SASPROGRAMFILE=; 41 %LET _SASPROGRAMFILEHOST=; 42 43 ;*';*";*/;quit;run; 44 ODS _ALL_ CLOSE; 45 46 47 QUIT; RUN;
Just as I suspected, SAS thinks everything is fine.
By the way, @RyanJB, it makes the log a lot easier to read if you post it via the "Insert Code" feature here on the forum.
Let me think about this some more...
Jim
What is causing an image to be generated? I don't see that in your code.
Vince DelGobbo
SAS R&D
Replying to both of your posts:
I was trying to anonymize what I posted and do it quickly, and one of those didn't work out so well! The escape character does not show up in my data, and there shouldn't be other special characters. I'm going to check out the XML as @jimbarbour suggested and try running it on a small subset of data I can easily vet. It is my own data, though.
As to why it's trying to generate an image, I'm not sure. I did create a pdf with ODS earlier (without issue), but I closed it as well.
If you're using an interactive SAS session like Enterprise Guide, Display Manager ("PC SAS"), etc., sometimes it's best to close the session and re-open it. A close and re-open will clear hard to reset things, things which might generate that PNG message (even though you're not using any images).
Jim
I am using EG, and the hard close/open seems to have solved it. I'm going to dig through the XML a little more and can let you know what differences I find between the corrupted one and the uncorrupted one, but I suspect it's to do with headers and footers included on the pdfs I generate earlier in the code (which I mentioned in a reply to @Vince_SAS). There's an odd (literally!) note in the XML file:
<headerFooter> <oddHeader>*** lots of text *** even more text *** </oddHeader> <oddFooter>bottom text filename.pdf</oddFooter> </headerFooter>
I suppose if headers/footers are generated as images, that could be what the issue is.
Thank you very much for your help!
The file location displayed in the SAS log does not match the code that you initially posted. This isn't really a problem, unless the code that generated the log is different from the code that you initially posted.
Are you using data from SASHELP.PRDSALE as described in the paper, or your own data. If your own data, then there could be a character that is causing the error, especially if the value specified in the ESCAPECHAR option is in the data.
Vince DelGobbo
SAS R&D
You may already know this, but Excel files are really just zipped XML. Can you do the following:
I'm in particular interested in the section that Excel said needed to be removed.
Jim
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!
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.
Ready to level-up your skills? Choose your own adventure.