Hi: I see a few problems with the code you posted that was based on my example using SASHELP.SHOES: -- font_weight is misspelled as font_wight several times -- it looks like you have Parentheses around the ESCAPECHAR style string, and it needs to be curly braces. The form of ODS ESCAPECHAR is like this: ods escapechar='^'; ^{style[attribute=value attr2=val2] varvalue } Notice the open and close curly brackets, not parens. The code I posted worked for me in ODS EXCEL. BTW, I'm not sure why you are turning ODS RESULTS OFF. That could have ill effect.
One cell in Excel cannot have 2 background colors. If Excel won't let a cell have 2 different background colors, SAS can't change how Excel works. Let's take SAS out of the picture. The text within an Excel cell can have 2 different FOREGROUND or FONT colors. That is what ODS ESCAPECHAR is doing in my example. But try this as an experiment. go into Excel. Type several lines into a cell like this:
If you highlight one of the lines and try to format cells, you will ONLY be presented in Excel with a choice to change the font characteristics, not the background fill.
after changing the text font to be different colors, I get this:
Now, if I highlight the cell and then choose Format Cells, I can change the background fill for the entire cell:
(changed the font back to black so it would not look too garish).
SAS is out of the picture in the above example, this is purely Excel formatting. And Excel doesn't allow one cell to have 2 backgrounds.
@Tom is correct. the first argument to CALL DEFINE has to be a column name (or the special tokes _COL_ and _ROW_ or an absolute column number). You have this:
call define("compress(substr(dt,12,8))",'style','style = [background = yellow]'); call define("compress(substr(bdt,12,8))", 'style','style = [background = yellow]');
That is not going to work for 2 reasons:
1) from the SAS/PROC REPORT end of things, you can't use a variable value from SUBSTR as the first argument to CALL DEFINE
2) from the Excel side of things, you can't have 2 different backgrounds in one cell in Excel
I guess I don't understand the purpose of having 2 different background colors in one cell.
But, with both SAS and Excel 2 different variable values in 2 different cells could have 2 different backgrounds:
and I can change the backgrounds (for an entire cell) conditionally like this:
Hope this helps.
Cynthia
... View more