BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
George12
Fluorite | Level 6

Hi all,

 

I've spent a while working on the following code:

 

ODS EXCEL FILE = "/filepath/filename.xlsx";
ODS EXCEL OPTIONS
	(PRINT_FOOTER = "&LForename Surname
Position&C&BDocument Name
Document Subname&RTime
Date");

 

The code works fine, and it creates this footer at the bottom of my Excel document:

 

image.png

 

This is exactly what I want, EXCEPT that I want the text for the middle footnotes (i.e. Document Name and Document Subname) to be in red, not black. How do I change this?

 

I've tried searching for a solution on Google. The only potential option which I've found is to insert &Color=RED, right before 'Document Name'. However, when I try it, it doesn't work. The &C is read as a separate command to centrally justify that footnote, and I'm left with a footnote that looks like: OLOR=REDDocument Name

 

Any help would be greatly appreciated. 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
George12
Fluorite | Level 6

Hi again @jimbarbour,

 

I've worked it out! Thanks for pointing me in the right direction. 😀

 

Following your suggestion, I searched on Google for specifically VBA &color solutions. Apparently, you need to use &K (who knew?) and then the hexidecimal color value.

 

So, the final code looks this:

 

ODS EXCEL FILE = "/filepath/filename.xlsx";
ODS EXCEL OPTIONS
	(PRINT_FOOTER = "&LForename Surname
Position&C&B&KFF0000Document Name
Document Subname&RTime
Date");

Works perfectly now. 😊

 

View solution in original post

6 REPLIES 6
jimbarbour
Meteorite | Level 14

Hi, @George12,

 

May I ask which SAS product you are using? I am using SAS 9.4 M6.

 

In SAS, in just about every context I can think of, &C would invoke the macro language processor.  What if you were to try just "color" without the preceding ampersand?

 

This code:

ODS	Excel	CLOSE;

OPTION	Device=ACTXIMG;
TITLE	"Test Report";
FOOTNOTE	color=red "Red " color=green " Green " color=blue "Blue";
ODS	Excel
	OPTIONS(
		Frozen_Headers="1"
		Frozen_RowHeaders="1"
		Sheet_Name="Test"
		Embedded_Titles="YES"
		Embedded_Footnotes="YES"
		Embed_Footnotes_Once="YES"
		Gridlines="YES"
		);

PROC	PRINT	DATA=SASHELP.Cars (OBS=15);
RUN;

ODS	Excel CLOSE;

The color in the footnotes appears to match what I coded; see below. Note that I just used a regular footnote rather than PRINT_FOOTER.  

 

Jim

 

jimbarbour_0-1628896901531.png

 

 

George12
Fluorite | Level 6

Hi @jimbarbour,

 

Thank you for your response. I am using SAS 8.3.

 

I do really appreciate your taking the time to respond, but I'm afraid that it doesn't help to solve my specific problem.

 

I tried using your code. Changing the text colour only seems to work if the footer is embedded, and I don't want an embedded footer. I also can't see how to use that code format to create two lines for seperate left, central, and right footnotes.

 

The &color is a VBA code, taken from here: https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2007/bb225426(v=office.12). Note that the other codes here (e.g. &L, &C, &R, &B, etc.) seem to work fine, but not &color.

 

I tried adding color=red - without the ampersand, as you suggested - into my existing code, but that's just read as text (i.e. so the footnote results in color=redDocument Name).

jimbarbour
Meteorite | Level 14

@George12,

 

Well, shoot, but I sort of thought "that can't be the solution; it's too easy."

 


@George12 wrote:

The &color is a VBA code, taken from here: https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2007/bb225426(v=office.12). Note that the other codes here (e.g. &L, &C, &R, &B, etc.) seem to work fine, but not &color.


Well, then it seems that it's a Microsoft VBA issue, yes?  I wonder if there are any VBA forums where someone may have encountered this. 

 

It is as though the VBA interpreter isn't able to properly distinguish between &c and &color.  It looks like VBA gets to "&c", interprets it as a command to center, and doesn't bother looking at the "olor".  If a look at VBA forums doesn't unearth a resolution, I wonder if there's a way to instruct VBA to handle "&color" as a whole rather than as "&c" and plain text "olor".  In SAS, I might do something like %NRSTR(&color) or %BQUOTE(&color).  I wonder if there's a way to do that in VBA.

 

Jim

George12
Fluorite | Level 6

Hi again @jimbarbour,

 

I've worked it out! Thanks for pointing me in the right direction. 😀

 

Following your suggestion, I searched on Google for specifically VBA &color solutions. Apparently, you need to use &K (who knew?) and then the hexidecimal color value.

 

So, the final code looks this:

 

ODS EXCEL FILE = "/filepath/filename.xlsx";
ODS EXCEL OPTIONS
	(PRINT_FOOTER = "&LForename Surname
Position&C&B&KFF0000Document Name
Document Subname&RTime
Date");

Works perfectly now. 😊

 

jimbarbour
Meteorite | Level 14

Excellent!  Sometimes all we need is a different perspective or approach to shake loose the solution.  

 

Jim

Sofya982
Calcite | Level 5

Click the "Home" tab. Click the small "Down Arrow" in the bottom right corner of the Font section of the ribbon. Click on the "Superscript" box to insert a check mark, then click “OK.” The footnote takes on the traditional, small and slightly higher appearance compared to normal text. This is how you can add footnote in excel in seconds. 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 6 replies
  • 1602 views
  • 1 like
  • 3 in conversation