The SAS Output Delivery System and reporting techniques

ODS highlighting duplicate row columns

Reply
Frequent Contributor
Posts: 123

ODS highlighting duplicate row columns

data test(keep=ln_no,upd_date);

set test2;

run;

sample data

ln_no       upd_date

1111       6/15/14

1122       9/5/11   

1122       9/11/15   (repeated)

1444      8/15/11

1166      2/8/11

1166    12/5/15   (repeated)

 

In ODS is there a way to place a highlight color say orange or red to highlight the ln_no column if the ln_no repeats on the next line.

In this case 1122 and 1166 repeated and I want to identify them as repeats. 

1122

1166

SAS Super FREQ
Posts: 8,643

Re: ODS highlighting duplicate row columns

Hi:

  It is very easy to do if you just want the duplicate value "blanked out" as shown in #1 below. If you make a "helper" variable using BY group processing and make a counter whose value will be GT 1 for the dups, then you can easily highlight a cell (#3) or a whole row (#4), as shown below.

 

cynthia

 

hilite_dups.png

Frequent Contributor
Posts: 123

Re: ODS highlighting duplicate row columns

Thanks, this works.  It will show highlight the last entriy in this case ln_no in a color based on the lag function

So in this case

1111

1111  the last entry will have the color background.

 

Is there a way to get both to show the color background and not just the last entry

SAS Super FREQ
Posts: 8,643

Re: ODS highlighting duplicate row columns

Hi,
Yes, that is possible, but not part of what you originally asked for. In order to do that, the LN_NO variable has to be defined as an ORDER variable. Do you want to see the LN_NO value on every row or not? The answer to that question has an impact on the PROC REPORT code that you will need. For this modification, you would NOT need to use the LAG approach.

cynthia

New User
Posts: 1

Re: ODS highlighting duplicate row columns

This was very easy to follow and helpful! Thank you.

Grand Advisor
Posts: 9,320

Re: ODS highlighting duplicate row columns

data test;
input ln_no       upd_date : mmddyy10.;
format upd_date mmddyy10.;
cards;
1111       6/15/14
1122       9/5/11   
1122       9/11/15  
1444      8/15/11
1166      2/8/11
1166    12/5/15  
;
run;

proc report data=test nowd;
columns ln_no upd_date;
define ln_no/display;
define upd_date/display;
compute upd_date;
 if ln_no eq lag(ln_no) then 
 call define(_row_,'style','style={background=orange}'); 
endcomp;
run;


SAS Super FREQ
Posts: 8,643

Re: ODS highlighting duplicate row columns

Hi: Yes, using LAG directly, is possible, however, your report ONLY works if LN_NO is given a usage of DISPLAY. With a usage of ORDER, the report does not work anymore.

cynthia
Post a Question
Discussion Stats
  • 6 replies
  • 408 views
  • 6 likes
  • 4 in conversation