0

I am trying to output SAS DS with multiple columns into excel and want to show two columns' name/label with two different colors. Please see the expected example output below:

enter image description here

So I need both black and red colors in one cell label. I have done this for the cell rows using ^{style option but same doesn't work for labels.

Sample code:

data test;
input lab s1 $ s2 $;
datalines;
1 A1 A2
2 B1 B2
3 C1 C2
;
run;

proc report data=test nowindows missing    
    style(column)=[foreground=black background=WHITE font_face=arial font_size=10pt just=center ]
    style(header)=[foreground=black background=white font_face=arial font_size=10pt just=center fontweight=bold];
    column lab s1 s2;
    
    define lab/"Lab Number" center;
    define s1/"sample 1 (Use this on Primary page)" center;
    define s2/"sample 2 (Use this on Secondary page)" center;
run;

Please suggest how this can be done? Thank You.

Rhythm
  • 680
  • 5
  • 9

1 Answers1

1

Use inline styling via ODSESCAPECHAR. ^{inline-directive text}

ods escapechar = '^';

proc report data=test nowindows missing    
    style(column)=[foreground=black background=WHITE font_face=arial font_size=10pt just=center ]
    style(header)=[foreground=black background=white font_face=arial font_size=10pt just=center fontweight=bold];
    column lab s1 s2;
    
    define lab/"Lab Number" center;
    define s1/"sample 1 ^{newline}^{style[color=red](Use this on Primary page)}" center;
    define s2/"sample 2 ^{newline}^{style[color=red](Use this on Secondary page)}" center;
run;

enter image description here

Richard
  • 25,390
  • 3
  • 25
  • 38