BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pax
Calcite | Level 5 pax
Calcite | Level 5
Is there an easy way conditionally to put a different format to the rows in output from PRINT or REPORT.
I.e. I would like to print all the rows where sex='F' with bold font and red background:

ods html style=sasweb;
proc print data=sashelp.class;
id name;
run;
ods html close;
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26

Hi:
PROC PRINT allow you to perform traffic lighting on particular cells, while PROC REPORT allows you to perform row level conditional highlighting using the CALL DEFINE statement.

Some sample code is below.

 

ods html file='style_rept.html' style=sasweb;

proc report data=sashelp.class nowd;
	title 'Conditional Row Highlighting';
	column name sex age height;
	define name / order;
	define sex / display;
	define age /display;
	define height /display;
	compute sex;
		if sex = 'F' then
			do;
				call define(_ROW_,'style','style={background=red font_weight=bold}');
			end;
	endcomp;
run;

ods html close;


cynthia

View solution in original post

1 REPLY 1
Cynthia_sas
Diamond | Level 26

Hi:
PROC PRINT allow you to perform traffic lighting on particular cells, while PROC REPORT allows you to perform row level conditional highlighting using the CALL DEFINE statement.

Some sample code is below.

 

ods html file='style_rept.html' style=sasweb;

proc report data=sashelp.class nowd;
	title 'Conditional Row Highlighting';
	column name sex age height;
	define name / order;
	define sex / display;
	define age /display;
	define height /display;
	compute sex;
		if sex = 'F' then
			do;
				call define(_ROW_,'style','style={background=red font_weight=bold}');
			end;
	endcomp;
run;

ods html close;


cynthia

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
  • 1 reply
  • 5617 views
  • 0 likes
  • 2 in conversation