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
SAS Super FREQ

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
SAS Super FREQ

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
SAS Super FREQ
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

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
  • 6 replies
  • 1754 views
  • 6 likes
  • 4 in conversation