BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

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

6 REPLIES 6
Cynthia_sas
Diamond | Level 26

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

Q1983
Lapis Lazuli | Level 10

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

Cynthia_sas
Diamond | Level 26

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

MGuidry
Calcite | Level 5

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

Ksharp
Super User
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;


Cynthia_sas
Diamond | Level 26
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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 2915 views
  • 6 likes
  • 4 in conversation