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
11 | 16 | 1,090 |
11 | BL | 160 |
11 | CI | 68 |
11 | MA | 1,282 |
12 | BL | 295 |
12 | CI | 348 |
12 | MA | 6,821 |
12 | MB | 76 |
21 | BL | 32 |
21 | CI | 54 |
21 | HM | 5,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
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;
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;
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.
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.