<?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 cells in specific column based on values in other column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Color-cells-in-specific-column-based-on-values-in/m-p/965929#M375999</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to color cells in specific column based on values in other column.&lt;/P&gt;
&lt;P&gt;I have tried this code but in output result i dont see colors&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 
data LONG1;                                                                                                                            
Input WD EXPD RCVD RCVD_ALL _NEWC_  $;                                                                                                                 
cards;    
-1 49 49 56 Y
01 26 26 77 Y
02 77 45 0 N
03 71 0 0 N
04 44 0 0 N
;
RUN;



proc report data=LONG1 missing nowd;
	column  (WD, ( EXPD RCVD RCVD_ALL));
	define WD / 'Working Day' across  /*NOZERO*/ ORDER=DATA;
	define EXPD / analysis 'Expd' missing;
	define RCVD / analysis 'Rcvd' missing;
	define RCVD_ALL / analysis 'Rcvd all' missing;

	compute RCVD;
		if _NEWC_ = "Y" then
			do;
				call define (_col_,"style", "style={background=green}");
			end;
		else if _NEWC_ = "N" then
			do;
				call define (_col_,"style", "style={background=red}");
			end;
	endcomp;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 07 May 2025 04:51:32 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2025-05-07T04:51:32Z</dc:date>
    <item>
      <title>PROC REPORT-Color cells in specific column based on values in other column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Color-cells-in-specific-column-based-on-values-in/m-p/965929#M375999</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to color cells in specific column based on values in other column.&lt;/P&gt;
&lt;P&gt;I have tried this code but in output result i dont see colors&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 
data LONG1;                                                                                                                            
Input WD EXPD RCVD RCVD_ALL _NEWC_  $;                                                                                                                 
cards;    
-1 49 49 56 Y
01 26 26 77 Y
02 77 45 0 N
03 71 0 0 N
04 44 0 0 N
;
RUN;



proc report data=LONG1 missing nowd;
	column  (WD, ( EXPD RCVD RCVD_ALL));
	define WD / 'Working Day' across  /*NOZERO*/ ORDER=DATA;
	define EXPD / analysis 'Expd' missing;
	define RCVD / analysis 'Rcvd' missing;
	define RCVD_ALL / analysis 'Rcvd all' missing;

	compute RCVD;
		if _NEWC_ = "Y" then
			do;
				call define (_col_,"style", "style={background=green}");
			end;
		else if _NEWC_ = "N" then
			do;
				call define (_col_,"style", "style={background=red}");
			end;
	endcomp;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 May 2025 04:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Color-cells-in-specific-column-based-on-values-in/m-p/965929#M375999</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-05-07T04:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT-Color cells in specific column based on values in other column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Color-cells-in-specific-column-based-on-values-in/m-p/965931#M376000</link>
      <description>&lt;PRE&gt;data LONG1;                                                                                                                            
Input WD EXPD RCVD RCVD_ALL &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;_NEWC_ &lt;/STRONG&gt; &lt;/FONT&gt;;                                                                                                                 
cards;    
-1 49 49 56 &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/FONT&gt;
01 26 26 77 &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/FONT&gt;
02 77 45 0 0
03 71 0 0 0
04 44 0 0 0
;
RUN;



proc report data=LONG1 missing nowd out=out ;
	column  (WD, ( EXPD RCVD RCVD_ALL  &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;_NEWC_ &lt;/STRONG&gt; &lt;/FONT&gt;)) ;
	define WD / 'Working Day' across  /*NOZERO*/ ORDER=DATA;
	define EXPD / analysis 'Expd' missing;
	define RCVD / analysis 'Rcvd' missing;
	define RCVD_ALL / analysis 'Rcvd all' missing;
  &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;  define _NEWC_/analysis noprint;&lt;/STRONG&gt;&lt;/FONT&gt;

	compute _NEWC_;
		if &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;_c4_&lt;/STRONG&gt;&lt;/FONT&gt; = 1 then
			do;
				call define ('&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;_c2_&lt;/STRONG&gt;&lt;/FONT&gt;',"style", "style={background=green}");
			end;
		else if _c4_= 0 then
			do;
				call define ('_c2_',"style", "style={background=red}");
			end;


		if _c8_ = 1 then
			do;
				call define ('_c6_',"style", "style={background=green}");
			end;
		else if _c8_= 0 then
			do;
				call define ('_c6_',"style", "style={background=red}");
			end;


		if _c12_ = 1 then
			do;
				call define ('_c10_',"style", "style={background=green}");
			end;
		else if _c12_= 0 then
			do;
				call define ('_c10_',"style", "style={background=red}");
			end;


		if _c16_ = 1 then
			do;
				call define ('_c14_',"style", "style={background=green}");
			end;
		else if _c16_= 0 then
			do;
				call define ('_c14_',"style", "style={background=red}");
			end;


	  if _c20_ = 1 then
			do;
				call define ('_c18_',"style", "style={background=green}");
			end;
		else if _c20_= 0 then
			do;
				call define ('_c18_',"style", "style={background=red}");
			end;
	endcomp;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1746595525646.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/106771i0FCE0D914A069F32/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1746595525646.png" alt="Ksharp_0-1746595525646.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 May 2025 05:25:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Color-cells-in-specific-column-based-on-values-in/m-p/965931#M376000</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-05-07T05:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT-Color cells in specific column based on values in other column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Color-cells-in-specific-column-based-on-values-in/m-p/965941#M376002</link>
      <description>&lt;P&gt;Proc Report builds reports from left to right. So basically any condition cannot see values of a column that is to the right as they have not been populated yet. And you have generally&amp;nbsp; have to specify the variables on the COLUMNS statement, i.e. _NEWC_ , so the variable order can be determined. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can specify NOPRINT on a Define so a variable does not appear in the report but the values can be used, such as the following. Adding _Newc_ in the first column with Noprint means its value is available for reference by any other column.&lt;/P&gt;
&lt;PRE&gt;proc report data=LONG1 missing nowd;
	column _NEWC_ (WD, ( EXPD RCVD RCVD_ALL));
   define _newc_ / noprint;
	define WD / 'Working Day' across  /*NOZERO*/ ORDER=DATA;
	define EXPD / analysis 'Expd' missing;
	define RCVD / analysis 'Rcvd' missing;
	define RCVD_ALL / analysis 'Rcvd all' missing;

	compute RCVD;
		if _NEWC_ = "Y" then
			do;
				call define (_col_,"style", "style={background=green}");
			end;
		else if _NEWC_ = "N" then
			do;
				call define (_col_,"style", "style={background=red}");
			end;
	endcomp;
run;
quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 May 2025 10:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Color-cells-in-specific-column-based-on-values-in/m-p/965941#M376002</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-05-07T10:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT-Color cells in specific column based on values in other column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Color-cells-in-specific-column-based-on-values-in/m-p/966027#M376011</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;In order to test the "_NEWC_" variable inside your PROC REPORT code, it MUST be on the COLUMN statement for PROC REPORT. Even if you have the variable in your data, PROC REPORT has to know about the variable before you can use it in an IF statement in a COMPUTE block. Then, as indicated, the placement of the variable on the COLUMN statement makes a difference. So if you are going to test the "_NEWC_" variable in the COMPUTE block for RCVD then it has to appear BEFORE RCVD in the COLUMN statement. There are other methods that may work too, but they are more complex.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Wed, 07 May 2025 22:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Color-cells-in-specific-column-based-on-values-in/m-p/966027#M376011</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2025-05-07T22:15:23Z</dc:date>
    </item>
  </channel>
</rss>

