<?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 Re: color cells based on other cells values-proc report in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972734#M377559</link>
    <description>"I didnt see any information to read about this rule "&lt;BR /&gt;Why not make an example to test this rule ?</description>
    <pubDate>Mon, 18 Aug 2025 05:11:14 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2025-08-18T05:11:14Z</dc:date>
    <item>
      <title>color cells based on other cells values-proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972723#M377554</link>
      <description>&lt;P&gt;Hello friends,&lt;/P&gt;
&lt;P&gt;I want to use proc report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wan to color the dif columns based on same cell value.&lt;BR /&gt;Here It was done 100% well.&lt;BR /&gt;If dif_P10&amp;gt;0.05 then I want to color&amp;nbsp; dif_P10 in red&lt;BR /&gt;If dif_P20&amp;gt;0.05 then I want to color&amp;nbsp; dif_P20 in red&lt;BR /&gt;If dif_P30&amp;gt;0.05 then I want to color&amp;nbsp; dif_P30 in red&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also want to color cells based on other cells values.&lt;/P&gt;
&lt;P&gt;If dif_P10&amp;gt;0.05 then I want to color&amp;nbsp; P10 in red&lt;/P&gt;
&lt;P&gt;If dif_P20&amp;gt;0.05 then I want to color&amp;nbsp; P20 in red&lt;/P&gt;
&lt;P&gt;If dif_P30&amp;gt;0.05 then I want to color&amp;nbsp; P30 in red&lt;/P&gt;
&lt;P&gt;and so on&lt;/P&gt;
&lt;P&gt;Here I dont know how to do it.&lt;/P&gt;
&lt;P&gt;Can anyone help please?&lt;/P&gt;
&lt;P&gt;I tried use code with column location but it didnt work&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;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

		data have;
		input P_IND_Prob mon  P10 P20 P30 P40 P50 P60 P70 P80 P90;
		cards;
		0 202507 0.1 0.15 0.25 0.31 0.49 0.46 0.6 0.75 0.8 0.97
		0 202506 0.08 0.13 0.14 0.44 0.52 0.65 0.74 0.82 0.91 0.94
		;
		run;
		proc sort data=have;
		by mon;
		run;

		data have2;
		set have;
		by mon;
		dif_p10 =abs(p10-lag(p10));
		dif_p20 =abs(p20-lag(p20)); 
		dif_p30 =abs(p30-lag(p30)); 
		dif_p40 =abs(p40-lag(p40)); 
		dif_p50 =abs(p50-lag(p50));
		dif_p60 =abs(p60-lag(p60)); 
		dif_p70 =abs(p70-lag(p70));
		dif_p80 =abs(p80-lag(p80));
		dif_p90 =abs(p90-lag(p90));
		run;


Proc format ;
value highlight_S4_Fmt
0.05&amp;lt;-high = 'red'
;
Run;

proc report data=have2 missing nowd  style(report)={frame=box font_size=8pt  bordercolor=black borderwidth=2px} ;
column 
mon
P10
P20
P30
P40
P50
P60
P70
P80
P90
dif_p10
dif_p20
dif_p30
dif_p40
dif_p50
dif_p60
dif_p70
dif_p80
dif_p90
;
define   mon/DISPLAY  ;
define   P10/DISPLAY   f=percent10.4 ;
define   P20/DISPLAY  f=percent10.4;
define   P30/DISPLAY   f=percent10.4;
define   P40/DISPLAY   f=percent10.4;
define   P50/DISPLAY   f=percent10.4;
define   P60/DISPLAY  f=percent10.4;
define   P70/DISPLAY  f=percent10.4;
define   P80/DISPLAY  f=percent10.4;
define   P90/DISPLAY  f=percent10.4;
define   dif_p10/DISPLAY f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p20/DISPLAY f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p30/DISPLAY f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p40/DISPLAY  f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p50/DISPLAY  f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p60/DISPLAY  f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p70/DISPLAY f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p80/DISPLAY  f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p90/DISPLAY  f=percent10.4   style=[background=highlight_S4_Fmt.];
Run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 17 Aug 2025 13:52:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972723#M377554</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-08-17T13:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: color cells based on other cells values-proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972724#M377555</link>
      <description>&lt;P&gt;&amp;nbsp;tried this code but it didnt work!&lt;/P&gt;
&lt;P&gt;Dif columsn are not colored based on the criteria&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=have2 missing nowd  style(report)={frame=box font_size=8pt  bordercolor=black borderwidth=2px} ;
column 
mon
P10
P20
P30
P40
P50
P60
P70
P80
P90
dif_p10
dif_p20
dif_p30
dif_p40
dif_p50
dif_p60
dif_p70
dif_p80
dif_p90
;
define   mon/DISPLAY  ;
define   P10/DISPLAY   f=percent10.4 ;
define   P20/DISPLAY  f=percent10.4;
define   P30/DISPLAY   f=percent10.4;
define   P40/DISPLAY   f=percent10.4;
define   P50/DISPLAY   f=percent10.4;
define   P60/DISPLAY  f=percent10.4;
define   P70/DISPLAY  f=percent10.4;
define   P80/DISPLAY  f=percent10.4;
define   P90/DISPLAY  f=percent10.4;
define   dif_p10/DISPLAY f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p20/DISPLAY f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p30/DISPLAY f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p40/DISPLAY  f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p50/DISPLAY  f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p60/DISPLAY  f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p70/DISPLAY f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p80/DISPLAY  f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p90/DISPLAY  f=percent10.4   style=[background=highlight_S4_Fmt.];
	compute P10;
	if dif_p10&amp;gt;0.05 then  	call define (_col_,"style", "style={background=red}");
	endcomp;

	compute P20;
	if dif_p20&amp;gt;0.05 then  	call define (_col_,"style", "style={background=red}");
	endcomp;

	compute P30;
	if dif_p30&amp;gt;0.05 then  	call define (_col_,"style", "style={background=red}");
	endcomp;

	compute P40;
	if dif_p40&amp;gt;0.05 then  	call define (_col_,"style", "style={background=red}");
	endcomp;

	compute P50;
	if dif_p50&amp;gt;0.05 then  	call define (_col_,"style", "style={background=red}");
	endcomp;

	compute P60;
	if dif_p60&amp;gt;0.05 then  	call define (_col_,"style", "style={background=red}");
	endcomp;

	compute P70;
	if dif_p70&amp;gt;0.05 then  	call define (_col_,"style", "style={background=red}");
	endcomp;

	compute P80;
	if dif_p80&amp;gt;0.05 then  	call define (_col_,"style", "style={background=red}");
	endcomp;

	compute P90;
	if dif_p90&amp;gt;0.05 then  	call define (_col_,"style", "style={background=red}");
	endcomp;
	Run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 17 Aug 2025 14:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972724#M377555</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-08-17T14:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: color cells based on other cells values-proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972729#M377556</link>
      <description>&lt;P&gt;PROC REPORT scan table from left to right.&lt;/P&gt;
&lt;P&gt;So when you want to refer to left column base on right column, you need use right column within COMPUTE block.&lt;/P&gt;
&lt;PRE&gt;		data have;
		input P_IND_Prob mon  P10 P20 P30 P40 P50 P60 P70 P80 P90;
		cards;
		0 202507 0.1 0.15 0.25 0.31 0.49 0.46 0.6 0.75 0.8 0.97
		0 202506 0.08 0.13 0.14 0.44 0.52 0.65 0.74 0.82 0.91 0.94
		;
		run;
		proc sort data=have;
		by mon;
		run;

		data have2;
		set have;
		by mon;
		dif_p10 =abs(p10-lag(p10));
		dif_p20 =abs(p20-lag(p20)); 
		dif_p30 =abs(p30-lag(p30)); 
		dif_p40 =abs(p40-lag(p40)); 
		dif_p50 =abs(p50-lag(p50));
		dif_p60 =abs(p60-lag(p60)); 
		dif_p70 =abs(p70-lag(p70));
		dif_p80 =abs(p80-lag(p80));
		dif_p90 =abs(p90-lag(p90));
		run;


Proc format ;
value highlight_S4_Fmt
0.05&amp;lt;-high = 'red'
;
Run;
proc report data=have2 missing nowd  style(report)={frame=box font_size=8pt  bordercolor=black borderwidth=2px} ;
column 
mon
P10
P20
P30
P40
P50
P60
P70
P80
P90
dif_p10
dif_p20
dif_p30
dif_p40
dif_p50
dif_p60
dif_p70
dif_p80
dif_p90
;
define   mon/DISPLAY  ;
define   P10/DISPLAY   f=percent10.4 ;
define   P20/DISPLAY  f=percent10.4;
define   P30/DISPLAY   f=percent10.4;
define   P40/DISPLAY   f=percent10.4;
define   P50/DISPLAY   f=percent10.4;
define   P60/DISPLAY  f=percent10.4;
define   P70/DISPLAY  f=percent10.4;
define   P80/DISPLAY  f=percent10.4;
define   P90/DISPLAY  f=percent10.4;
define   dif_p10/DISPLAY f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p20/DISPLAY f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p30/DISPLAY f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p40/DISPLAY  f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p50/DISPLAY  f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p60/DISPLAY  f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p70/DISPLAY f=percent10.4   style=[background=highlight_S4_Fmt.];
define   dif_p80/DISPLAY  f=percent10.4   style=[background=highlight_S4_Fmt.];
define   &lt;STRONG&gt;dif_p90&lt;/STRONG&gt;/DISPLAY  f=percent10.4   style=[background=highlight_S4_Fmt.];
	compute &lt;STRONG&gt;dif_p90&lt;/STRONG&gt;;
	if dif_p10&amp;gt;0.05 then  	call define (&lt;STRONG&gt;'P10'&lt;/STRONG&gt;,"style", "style={background=red}");
	if dif_p20&amp;gt;0.05 then  	call define (&lt;STRONG&gt;'P20'&lt;/STRONG&gt;,"style", "style={background=red}");
	if dif_p30&amp;gt;0.05 then  	call define ('P30',"style", "style={background=red}");
	if dif_p40&amp;gt;0.05 then  	call define ('P40',"style", "style={background=red}");
	if dif_p50&amp;gt;0.05 then  	call define ('P50',"style", "style={background=red}");
	if dif_p60&amp;gt;0.05 then  	call define ('P60',"style", "style={background=red}");
	if dif_p70&amp;gt;0.05 then  	call define ('P70',"style", "style={background=red}");
	if dif_p80&amp;gt;0.05 then  	call define ('P80',"style", "style={background=red}");
	if dif_p90&amp;gt;0.05 then  	call define ('P90',"style", "style={background=red}");
	endcomp;
	Run;
&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1755478798525.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109044iFF2A70AA3EED01AF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1755478798525.png" alt="Ksharp_0-1755478798525.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 01:00:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972729#M377556</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-08-18T01:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: color cells based on other cells values-proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972732#M377557</link>
      <description>&lt;P&gt;As I understand you wrote&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;compute &lt;STRONG&gt;dif_p90&lt;/STRONG&gt;;&lt;/PRE&gt;
&lt;P&gt;but you can type here any variable that appear in right of all dif variables&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;I didnt see any information to read about this rule -&lt;SPAN&gt;when you want to refer to left column base on right column, you need use right column within COMPUTE block&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 04:49:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972732#M377557</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-08-18T04:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: color cells based on other cells values-proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972733#M377558</link>
      <description>Yes. You are right.&lt;BR /&gt;As long as the variable in COMPUTE&lt;BR /&gt;compute dif_p90;&lt;BR /&gt;is at the right side of the variable you refer to (e.x. p90)</description>
      <pubDate>Mon, 18 Aug 2025 05:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972733#M377558</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-08-18T05:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: color cells based on other cells values-proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972734#M377559</link>
      <description>"I didnt see any information to read about this rule "&lt;BR /&gt;Why not make an example to test this rule ?</description>
      <pubDate>Mon, 18 Aug 2025 05:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972734#M377559</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-08-18T05:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: color cells based on other cells values-proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972738#M377560</link>
      <description>&lt;P&gt;And If there is no any variable on the right?&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;If variables order is - IND MON dif_P10 dif_ P20&amp;nbsp; dif_P30&amp;nbsp; P10 P20 P30&lt;/P&gt;
&lt;P&gt;And I want to -&lt;/P&gt;
&lt;P&gt;color&amp;nbsp;P10 bases on dif_p10&lt;/P&gt;
&lt;P&gt;color&amp;nbsp;P20 bases on dif_p20&lt;/P&gt;
&lt;P&gt;color&amp;nbsp;P30 bases on dif_p30&lt;/P&gt;
&lt;P&gt;But as you can see-&lt;/P&gt;
&lt;P&gt;dif_p10 is left to P10&lt;/P&gt;
&lt;P&gt;dif_p20 is left to P20&lt;/P&gt;
&lt;P&gt;dif_P30 is left to p30&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 07:54:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972738#M377560</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-08-18T07:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: color cells based on other cells values-proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972739#M377561</link>
      <description>&lt;P&gt;I see that the rule is true but I want to read a bit about it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 07:54:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972739#M377561</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-08-18T07:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: color cells based on other cells values-proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972744#M377562</link>
      <description>Then use the right most variable P30:&lt;BR /&gt;&lt;BR /&gt;compute P30;&lt;BR /&gt;	if dif_p10&amp;gt;0.05 then  	call define ('P10',"style", "style={background=red}");</description>
      <pubDate>Mon, 18 Aug 2025 08:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972744#M377562</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-08-18T08:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: color cells based on other cells values-proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972764#M377563</link>
      <description>&lt;P&gt;The following is in the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=v_063&amp;amp;docsetId=proc&amp;amp;docsetTarget=p111cb7rjuyuftn15pzvoq9bkoas.htm" target="_self"&gt;documentation&lt;/A&gt; under Required arguments:&lt;/P&gt;
&lt;P&gt;report-item&lt;BR /&gt;specifies a data set variable, a computed variable, or a statistic to associate the compute block with. You must include the report item in the COLUMN statement. If the item is a computed variable, then you must include a DEFINE statement for it.&lt;BR /&gt;&lt;STRONG&gt;Note The position of a computed variable is important. PROC REPORT assigns values to the columns in a row of a report from left to right. Consequently, you cannot base the calculation of a computed variable on any variable that appears to its right in the report.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I would also suggest the following paper:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings15/SAS1642-2015.pdf" target="_self"&gt;https://support.sas.com/resources/papers/proceedings15/SAS1642-2015.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 11:31:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/color-cells-based-on-other-cells-values-proc-report/m-p/972764#M377563</guid>
      <dc:creator>Kathryn_SAS</dc:creator>
      <dc:date>2025-08-18T11:31:28Z</dc:date>
    </item>
  </channel>
</rss>

