BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
nohassles
Obsidian | Level 7

SAS Community,

 

I have seen several good examples of PROC REPORT row highlighting when two colums have certain values but I can't seem to get it to work with my simple dataset.

 

PT1 SOP1 Count

11161,090
11BL160
11CI68
11MA1,282
12BL295
12CI348
12MA6,821
12MB76
21BL32
21CI54
21HM5,208

 

Columns Properties

Column Name  Type  Length  Format  Informat

PT1                  Text   5            $5.        $5.

SOP1               Text   2            $2.

 

I want to highlight the last row, PT1 = '21' and SOP='HM'.

 

Here is excerpt from my PROC REPORT code;

ODS listing close;

options orientation=landscape;

ods html file='d:\temp\demo_3_1.html' style=sasweb;

proc report data=paysrc.SW_freq_FACbyPTbyCFI_&clm._&yr. nowindows headline headskip split='*' style(header)=[fontsize=1] style(report)=[bordercolor = black] style(report)=[fontsize=-1] ;

options number nonumber nodate center;

BY facility;

columns PT1 SOP1 COUNT;

define PT1 / display 'Payment*Topology 1' style(column)=[fontsize=1];

define SOP1 / display 'Claim Filing*Indicator 1' style(column)=[fontsize=1];

define COUNT / display 'Frequency*Count' format=comma10. style(column)=[fontsize=1];

compute PT1;

if PT1 = '21' AND SOP1 = 'HM' then do;

call define (_row_,'style','style={background=cx9999cc}');

end;

endcomp;

 

TITLES;

FOOTNOTES;

RUN;

 

ods html close;

ODS listing;

 

If anyone has any ideas on what I can try next, I would appreciate hearing from you.

Stephen

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

I think it's an order of operations issues. 

It applies the background color but then moving on to SOP1 it resets it back to the original. Using SOP1 in your compute statement removes this issue.

 

compute SOP1;
if PT1 = 21 AND SOP1 = 'HM' then 
call define(_row_,"style","style={background=cx9999cc}");
endcomp;

 Full working code:

 



data have;
input pt1 sop1 $ count;
cards;
11 16 1090
11 BL 160
11 CI 68
11 MA 1282
12 BL 295
12 CI 348
12 MA 6821
12 MB 76
21 BL 32
21 CI 54
21 HM 5208
;
run;
proc print; run;



ODS listing close;
options orientation=landscape;
ods html file='c:\_localdata\demo_3_1.html' style=sasweb;
proc report data=have nowindows headline headskip split='*' style(header)=[fontsize=1] style(report)=[bordercolor = black] style(report)=[fontsize=-1] ;
options number nonumber nodate center;
columns PT1 SOP1 COUNT;
define PT1 / display 'Payment*Topology 1' style(column)=[fontsize=1];
define SOP1 / display 'Claim Filing*Indicator 1' style(column)=[fontsize=1];
define COUNT / display 'Frequency*Count' format=comma10. style(column)=[fontsize=1];
compute SOP1;
if PT1 = 21 AND SOP1 = 'HM' then
call define(_row_,"style","style={background=cx9999cc}");
endcomp;

RUN;quit;

ods html close;
ODS listing;

 

View solution in original post

2 REPLIES 2
Reeza
Super User

I think it's an order of operations issues. 

It applies the background color but then moving on to SOP1 it resets it back to the original. Using SOP1 in your compute statement removes this issue.

 

compute SOP1;
if PT1 = 21 AND SOP1 = 'HM' then 
call define(_row_,"style","style={background=cx9999cc}");
endcomp;

 Full working code:

 



data have;
input pt1 sop1 $ count;
cards;
11 16 1090
11 BL 160
11 CI 68
11 MA 1282
12 BL 295
12 CI 348
12 MA 6821
12 MB 76
21 BL 32
21 CI 54
21 HM 5208
;
run;
proc print; run;



ODS listing close;
options orientation=landscape;
ods html file='c:\_localdata\demo_3_1.html' style=sasweb;
proc report data=have nowindows headline headskip split='*' style(header)=[fontsize=1] style(report)=[bordercolor = black] style(report)=[fontsize=-1] ;
options number nonumber nodate center;
columns PT1 SOP1 COUNT;
define PT1 / display 'Payment*Topology 1' style(column)=[fontsize=1];
define SOP1 / display 'Claim Filing*Indicator 1' style(column)=[fontsize=1];
define COUNT / display 'Frequency*Count' format=comma10. style(column)=[fontsize=1];
compute SOP1;
if PT1 = 21 AND SOP1 = 'HM' then
call define(_row_,"style","style={background=cx9999cc}");
endcomp;

RUN;quit;

ods html close;
ODS listing;

 

nohassles
Obsidian | Level 7
Thank you very much!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 2 replies
  • 999 views
  • 1 like
  • 2 in conversation