<?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 exceeds LCL or UCL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-color-cell-If-exceeds-LCL-or-UCL/m-p/825124#M325902</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to color cells in column "Wealth"&amp;nbsp; by following rules:&lt;/P&gt;
&lt;P&gt;If value of wealth is higher than UCL or lower than LCL then color it in light Red.&lt;/P&gt;
&lt;P&gt;otherwise color it in light green.&lt;/P&gt;
&lt;P&gt;The problem is that as you see all cells are in light red so it is not as I want.&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 month welath LCL UCL;
cards;
111 1 900 330 895
111 2 700 330 895
111 3 800 330 895
111 4 300 330 895
111 5 400 330 895
111 6 800 330 895
111 7 800 330 895
111 8 750 330 895
111 9 100 330 895
111 10 200 330 895
111 11 700 330 895
111 12 900 330 895
;
Run;
PROC REPORT DATA=have nowd split='*' style(header)={background=lightgrey font_size=10pt} style(column)={font_size=10pt} 
style(report)={vjust=c just=c cellpadding=0pt};   
COLUMN  CustID month welath LCL UCL;
DEFINE  CustID/Display;
DEFINE  month/Display;
DEFINE  welath/Display;
DEFINE  LCL/Display;
DEFINE  UCL/Display;
compute welath; 
if    _C4_ &amp;lt;=_C3_&amp;lt;=_C5_  then call define (_COL_,'style','style={background=lightgreen}'); 
else call define (_COL_,'style','style={background=lightred}'); 
endcomp;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 24 Jul 2022 06:12:44 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2022-07-24T06:12:44Z</dc:date>
    <item>
      <title>Proc Report-color cell If exceeds LCL or UCL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-color-cell-If-exceeds-LCL-or-UCL/m-p/825124#M325902</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to color cells in column "Wealth"&amp;nbsp; by following rules:&lt;/P&gt;
&lt;P&gt;If value of wealth is higher than UCL or lower than LCL then color it in light Red.&lt;/P&gt;
&lt;P&gt;otherwise color it in light green.&lt;/P&gt;
&lt;P&gt;The problem is that as you see all cells are in light red so it is not as I want.&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 month welath LCL UCL;
cards;
111 1 900 330 895
111 2 700 330 895
111 3 800 330 895
111 4 300 330 895
111 5 400 330 895
111 6 800 330 895
111 7 800 330 895
111 8 750 330 895
111 9 100 330 895
111 10 200 330 895
111 11 700 330 895
111 12 900 330 895
;
Run;
PROC REPORT DATA=have nowd split='*' style(header)={background=lightgrey font_size=10pt} style(column)={font_size=10pt} 
style(report)={vjust=c just=c cellpadding=0pt};   
COLUMN  CustID month welath LCL UCL;
DEFINE  CustID/Display;
DEFINE  month/Display;
DEFINE  welath/Display;
DEFINE  LCL/Display;
DEFINE  UCL/Display;
compute welath; 
if    _C4_ &amp;lt;=_C3_&amp;lt;=_C5_  then call define (_COL_,'style','style={background=lightgreen}'); 
else call define (_COL_,'style','style={background=lightred}'); 
endcomp;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Jul 2022 06:12:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-color-cell-If-exceeds-LCL-or-UCL/m-p/825124#M325902</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-07-24T06:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-color cell If exceeds LCL or UCL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-color-cell-If-exceeds-LCL-or-UCL/m-p/825126#M325903</link>
      <description>&lt;P&gt;Your condition is an AND condition. Both comparisons must be satisfied. To get an OR, you need to split the condition and use OR.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jul 2022 07:29:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-color-cell-If-exceeds-LCL-or-UCL/m-p/825126#M325903</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-24T07:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-color cell If exceeds LCL or UCL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-color-cell-If-exceeds-LCL-or-UCL/m-p/825129#M325905</link>
      <description>&lt;P&gt;Sorry,I didn't understand.&lt;/P&gt;
&lt;P&gt;This code is also not working well- I get all cells of column wealth in red color and only few cells should be in red.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC REPORT DATA=have nowd split='*' style(header)={background=lightgrey font_size=10pt} style(column)={font_size=10pt} 
style(report)={vjust=c just=c cellpadding=0pt};   
COLUMN  CustID month welath LCL UCL;
DEFINE  CustID/Display;
DEFINE  month/Display;
DEFINE  welath/Display;
DEFINE  LCL/Display;
DEFINE  UCL/Display;
compute welath; 
IF _C3_&amp;lt;_C4_  OR  _C3_&amp;gt; _C5_ then call define (_COL_,'style','style={background=lightred}'); 
else call define (_COL_,'style','style={background=lightgreen}'); 
endcomp;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Jul 2022 09:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-color-cell-If-exceeds-LCL-or-UCL/m-p/825129#M325905</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-07-24T09:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-color cell If exceeds LCL or UCL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-color-cell-If-exceeds-LCL-or-UCL/m-p/825130#M325906</link>
      <description>&lt;P&gt;PROC REPORT works left to right, using the order in the COLUMN statement. You cannot do a comparison, such as _C3_&amp;lt;_C4_ using variables to the right of _C3_ (and _C4_ is obviously to the right of _C3_). So you need to have a version of LCL and UCL to the left of WEALTH, but which doesn't print.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
Input CustID month wealth LCL UCL;
cards;
111 1 900 330 895
111 2 700 330 895
111 3 800 330 895
111 4 300 330 895
111 5 400 330 895
111 6 800 330 895
111 7 800 330 895
111 8 750 330 895
111 9 100 330 895
111 10 200 330 895
111 11 700 330 895
111 12 900 330 895
;

PROC REPORT DATA=have;   
COLUMN  CustID month lcl=lcl1 ucl=ucl1 wealth LCL UCL;
DEFINE  CustID/Display;
DEFINE  month/Display;
DEFINE  wealth/Display;
DEFINE  LCL/Display;
DEFINE  UCL/Display;
define lcl1 / noprint;
define ucl1 / noprint;
compute wealth; 
IF wealth&amp;lt;lcl1 or wealth&amp;gt;ucl1 then call define (_col_,'style','style={background=lightred}'); 
else call define (_col_,'style','style={background=lightgreen}'); 
endcomp;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;People at SAS also recommend what I will call the "DUMMY technique" where you create a variable named DUMMY as the last variable in the COLUMN statement, which of course is to the right of all other variables since it is the last one, and then COMPUTE DUMMY works as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC REPORT DATA=have;   
COLUMN  CustID month wealth LCL UCL dummy;
DEFINE  CustID/Display;
DEFINE  month/Display;
DEFINE  wealth/Display;
DEFINE  LCL/Display;
DEFINE  UCL/Display;
define dummy / noprint;
compute dummy; 
if wealth&amp;lt;lcl or wealth&amp;gt;ucl then call define (3,'style','style={background=lightred}'); 
else call define (3,'style','style={background=lightgreen}'); 
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, even the DUMMY isn't necessary if you use COMPUTE UCL, because everything is to the left of UCL, nothing is to the right.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC REPORT DATA=have;   
COLUMN  CustID month wealth LCL UCL;
DEFINE  CustID/Display;
DEFINE  month/Display;
DEFINE  wealth/Display;
DEFINE  LCL/Display;
DEFINE  UCL/Display;
compute ucl; 
IF wealth&amp;lt;lcl or wealth&amp;gt;ucl then call define (3,'style','style={background=lightred}'); 
else call define (3,'style','style={background=lightgreen}'); 
endcomp;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jul 2022 11:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-color-cell-If-exceeds-LCL-or-UCL/m-p/825130#M325906</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-24T11:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-color cell If exceeds LCL or UCL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-color-cell-If-exceeds-LCL-or-UCL/m-p/825135#M325910</link>
      <description>&lt;P&gt;PROC REPORT is calculating from left to right, so you need put LCL and UCL before weight. Like this :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
Input CustID month welath LCL UCL;
cards;
111 1 900 330 895
111 2 700 330 895
111 3 800 330 895
111 4 300 330 895
111 5 400 330 895
111 6 800 330 895
111 7 800 330 895
111 8 750 330 895
111 9 100 330 895
111 10 200 330 895
111 11 700 330 895
111 12 900 330 895
;
Run;
PROC REPORT DATA=have nowd split='*' style(header)={background=lightgrey font_size=10pt} style(column)={font_size=10pt} 
style(report)={vjust=c just=c cellpadding=0pt};   
COLUMN  CustID month LCL UCL welath LCL=_LCL UCL=_UCL;
DEFINE  CustID/Display;
DEFINE  month/Display;
DEFINE  welath/Display;
DEFINE  LCL/noprint;
DEFINE  UCL/noprint;
DEFINE  _LCL/display 'LCL';
DEFINE  _UCL/display 'UCL';

compute welath; 
if    _C3_ &amp;lt;=_C5_&amp;lt;=_C4_  then call define (_COL_,'style','style={background=lightgreen}'); 
else call define (_COL_,'style','style={background=lightred}'); 
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="Ksharp_0-1658658513186.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73674i3BD3B1E30F9B134D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1658658513186.png" alt="Ksharp_0-1658658513186.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jul 2022 10:28:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-color-cell-If-exceeds-LCL-or-UCL/m-p/825135#M325910</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-07-24T10:28:38Z</dc:date>
    </item>
  </channel>
</rss>

