<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic PROC REPORT COLOR CELL IF in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-COLOR-CELL-IF/m-p/966055#M376016</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to create proc report that just display columns and color cells in following rule:&lt;/P&gt;
&lt;P&gt;If column x=1 then value in cell under column x get color&amp;nbsp; background&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If column w=1 then value in cell under column w get color&amp;nbsp; background&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and so on&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why I don't see any color in my results??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
input custId branchId x w z r t q ;
cards;
123456 111 0 0 1 0 0 1 
;
Run;
proc report data=have;
column 
custId
branchId
x
w 
z 
r 
t 
q
;
define custId/display;
define branchId/display;
define x/display;
define w/display;
define z/display;
define r/display;
define t/display;
define q/display;

COMPUTE x;
IF _COL_=1 then do;
CALL DEFINE(x, "style", "STYLE=[BACKGROUND=MISTYROSE]");
end;
ENDCOMP;

COMPUTE w;
IF _COL_=1 then do;
CALL DEFINE(w, "style", "STYLE=[BACKGROUND=MISTYROSE]");
end;
ENDCOMP;

COMPUTE z;
IF _COL_=1 then do;
CALL DEFINE(z, "style", "STYLE=[BACKGROUND=MISTYROSE]");
end;
ENDCOMP;


COMPUTE r;
IF _COL_=1 then do;
CALL DEFINE(r, "style", "STYLE=[BACKGROUND=MISTYROSE]");
end;
ENDCOMP;


COMPUTE t;
IF _COL_=1 then do;
CALL DEFINE(t, "style", "STYLE=[BACKGROUND=MISTYROSE]");
end;
ENDCOMP;


COMPUTE q;
IF _COL_=1 then do;
CALL DEFINE(q, "style", "STYLE=[BACKGROUND=MISTYROSE]");
end;
ENDCOMP;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 May 2025 09:29:10 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2025-05-08T09:29:10Z</dc:date>
    <item>
      <title>PROC REPORT COLOR CELL IF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-COLOR-CELL-IF/m-p/966055#M376016</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to create proc report that just display columns and color cells in following rule:&lt;/P&gt;
&lt;P&gt;If column x=1 then value in cell under column x get color&amp;nbsp; background&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If column w=1 then value in cell under column w get color&amp;nbsp; background&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and so on&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why I don't see any color in my results??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
input custId branchId x w z r t q ;
cards;
123456 111 0 0 1 0 0 1 
;
Run;
proc report data=have;
column 
custId
branchId
x
w 
z 
r 
t 
q
;
define custId/display;
define branchId/display;
define x/display;
define w/display;
define z/display;
define r/display;
define t/display;
define q/display;

COMPUTE x;
IF _COL_=1 then do;
CALL DEFINE(x, "style", "STYLE=[BACKGROUND=MISTYROSE]");
end;
ENDCOMP;

COMPUTE w;
IF _COL_=1 then do;
CALL DEFINE(w, "style", "STYLE=[BACKGROUND=MISTYROSE]");
end;
ENDCOMP;

COMPUTE z;
IF _COL_=1 then do;
CALL DEFINE(z, "style", "STYLE=[BACKGROUND=MISTYROSE]");
end;
ENDCOMP;


COMPUTE r;
IF _COL_=1 then do;
CALL DEFINE(r, "style", "STYLE=[BACKGROUND=MISTYROSE]");
end;
ENDCOMP;


COMPUTE t;
IF _COL_=1 then do;
CALL DEFINE(t, "style", "STYLE=[BACKGROUND=MISTYROSE]");
end;
ENDCOMP;


COMPUTE q;
IF _COL_=1 then do;
CALL DEFINE(q, "style", "STYLE=[BACKGROUND=MISTYROSE]");
end;
ENDCOMP;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2025 09:29:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-COLOR-CELL-IF/m-p/966055#M376016</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-05-08T09:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT COLOR CELL IF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-COLOR-CELL-IF/m-p/966062#M376017</link>
      <description>&lt;P&gt;Your syntax is not correct and MISTYROSE doesn't seem to be a color on my system.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input custId branchId x w z r t q ;
cards;
123456 111 0 0 1 0 0 1 
123456 111 1 0 1 0 0 1 
123456 111 0 1 1 0 0 1 
;
Run;
proc report data=have;
column custId branchId x w  z  r  t  q;
define custId/display;
define branchId/display;
define x/display;
define w/display;
define z/display;
define r/display;
define t/display;
define q/display;

COMPUTE x;
IF x=1 then do;
CALL DEFINE(_col_, "style", "STYLE=[BACKGROUND=pink]");
end;
ENDCOMP;

COMPUTE w;
IF w=1 then do;
CALL DEFINE(_col_, "style", "STYLE=[BACKGROUND=lightblue]");
end;
ENDCOMP;

COMPUTE z;
IF z=1 then do;
CALL DEFINE(_col_, "style", "STYLE=[BACKGROUND=lightgreen]");
end;
ENDCOMP;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 225px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/106804iF089B3E9A5EC3A92/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2025 12:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-COLOR-CELL-IF/m-p/966062#M376017</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2025-05-08T12:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT COLOR CELL IF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-COLOR-CELL-IF/m-p/966103#M376022</link>
      <description>&lt;P&gt;If you have multiple variables whose value and desired background color are identical it can be worth creating a custom format and using that in the Define statement for those variables instead of using compute blocks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note than any dataset containing data used to provide values that change appearance should include observations that do not display that characteristic (i.e. provide more observations ) so the code written for a solution has a chance of showing where the display change shouldn't occur and doesn't. Note that the alternate set that &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt; provides such.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;data have;
input custId branchId x w z r t q ;
cards;
123456 111 0 0 1 0 0 1 
123456 111 1 0 1 0 0 1 
123456 111 0 1 1 0 0 1 
;
Run;

proc format ;
value color_ones
1='Pink'
;
run;

proc report data=have;
column custId branchId x w  z  r  t  q;
define custId/display;
define branchId/display;
define x/display style=[background= color_ones.];
define w/display style=[background= color_ones.];
define z/display style=[background= color_ones.];
define r/display style=[background= color_ones.];
define t/display style=[background= color_ones.];
define q/display style=[background= color_ones.];

run;&lt;/PRE&gt;
&lt;P&gt;Note that one of the strong advantages of the format approach is that when your boss comes in says "Show the values of 2 as greeen" you only need to change ONE line in the program: add 2='green' to the format definition. I know this data doesn't have any values of 2 but are you sure that will not change in the future. Or if the boss says some of the variables should use a different color, then create similar format with the new color and change the name in the Define statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can address multiple display characteristics with this approach such a border line colors or widths, font or text weight, most of the items that can be addressed with a style option in a define statement. &lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2025 18:25:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-COLOR-CELL-IF/m-p/966103#M376022</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-05-08T18:25:18Z</dc:date>
    </item>
  </channel>
</rss>

