BookmarkSubscribeRSS Feed
112211
Obsidian | Level 7

112211_0-1738228913687.png

I need color coding, as mentioned in the title section 

Proc report data = sashelp.class ;

column  name age sex weight height ;

run;

 

6 REPLIES 6
112211
Obsidian | Level 7
Thanks for replay
I have gone through all those PDFs, but I'm not getting.
Amir
PROC Star

Hi,

 

So that people can more easily help you, please share 4 more things:

 

  1. The code you have tried.
  2. The result you received.
  3. The result you want.
  4. The SAS log, if there any issues reported in it.

 

Thanks & kind regards,

Amir.

ballardw
Super User

Color code what?

"Title" is normally part that goes before a report in SAS so coloring age doesn't make much sense in relation to "title".

To color a value based the value we need to know exactly what to color.

This example colors the background of cell that has the age.

proc format ;
value agecolor
11 = 'Yellow'
12, 13 =  'Red'
14, 15 = 'Black'
;
run;

Proc report data = sashelp.class ;
   column  name age sex weight height ;
   define name / group;
   define age / style=[background=agecolor.];

run;

 

Tom
Super User Tom
Super User

If I run your code I do not get any TITLE printed (unless I had previous run a TITLE statement).

Tom_0-1738246195652.png

Do you mean you want to change the colors of the column headers in your report?

You can do that with the STYLE option on the DEFINE statement in PROC REPORT.

proc report data = sashelp.class ;
  column  name age sex weight height ;
  define name / style(header)={backgroundcolor=red};
run;

Tom_1-1738246326529.png

 

Ksharp
Super User

1)

data class;
 set sashelp.class;
 length x $ 80;
 if age in (11:14) then x=cats('(*ESC*){style [foreground=yellow fontsize=2 fontweight=bold]||||||||}age_',age);
 else x=cats('(*ESC*){style [foreground=red fontsize=2 fontweight=bold]||||||||}age_',age);
 keep name age x;
 run;
ods excel file='c:\temp\temp.xlsx';
 proc report data=class nowd ;
 run;
ods excel close;

Ksharp_0-1738292008725.png

 

 

2)

data class;
 set sashelp.class;
 length x $ 80;
 y='||||||||'; x=cats('age_',age);
 keep name age y  x;
 run;
ods excel file='c:\temp\temp.xlsx';
 proc report data=class nowd ;
 column name age y x;
 define age/display;
 compute y;
 if age in (11:14) then call define(_col_,'style','style={background=yellow foreground=yellow}');
  else  call define(_col_,'style','style={background=red foreground=red}');
 endcomp;
 run;
ods excel close;

Ksharp_1-1738292354567.png

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1344 views
  • 2 likes
  • 6 in conversation