BookmarkSubscribeRSS Feed
mlogan
Lapis Lazuli | Level 10

Hi All,

I am stuck with highlighting some cells of a column based on a comparison of cells of another column. In the following code I tried to use CALL DEFINE so that it highlights when column _c2_ is bigger than _c3_. Can someone help me please.

 

PROC SQL;
CREATE TABLE sale AS 
SELECT country, 
	   region, 
       prodtype, 
       product, 
	   actual LABEL=''FORMAT=comma10.2,
	   predict LABEL=''FORMAT=comma10.2,
	   month
FROM sashelp.prdsale 
WHERE mod(monotonic(),75)=0
ORDER BY ranuni(94612);
QUIT;

PROC REPORT DATA=sale NOWINDOWS MISSING HEADLINE HEADSKIP OUT=test;
COLUMN country (region prodtype) , predict;
DEFINE country / GROUP;
DEFINE region / ACROSS;
DEFINE prodtype / ACROSS;
RBREAK AFTER / SUMMARIZE SKIP ol;
COMPUTE predict;
    IF _c2_>_c3_.sum THEN CALL DEFINE (_Col_, "style", "style={background=Yellow}");
ENDCOMP;
RUN;

 

 

 

4 REPLIES 4
PaigeMiller
Diamond | Level 26
proc report data=sale nowindows missing headline headskip out=test;
    column country (region prodtype) , predict;
    define country / group;
    define region / across;
    define prodtype / across;
    rbreak after / summarize skip ol;
    compute region;
        if _c2_>_c3_ then call define (_col_, "style", "style={background=yellow}");
    endcomp;
run;
--
Paige Miller
mlogan
Lapis Lazuli | Level 10
Hi PaigeMiller, Thanks for the code, but it is not producing the output according to the logic. With the logic IF _c2_>_c3_, the cell containing 1,982.00 should be highlighted only, but it is not working that way. Would you please look into it. Thanks.
kiranv_
Rhodochrosite | Level 12

it worked for me

 IF _c2_> _c3_ and country = ' ' THEN CALL DEFINE (_Col_, "style", "style={background=Yellow}");
mlogan
Lapis Lazuli | Level 10
Hi Kiranv, Thanks for the code, but it is not producing the output according to the logic. It is highlighting the total column. With the logic IF _c2_>_c3_, the cell containing 1,982.00 should be highlighted only, but it is not working that way. Would you please look into it. Thanks.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 4 replies
  • 1538 views
  • 0 likes
  • 3 in conversation