<?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: PROC REPORT coloring a field based on 2 other fields in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-coloring-a-field-based-on-2-other-fields/m-p/783605#M25492</link>
    <description>Hi Cynthia,&lt;BR /&gt;Sorry, next time I will add test data and screenshot. The problem was that I missed the .MEAN. I tried with .SUM, but not with .MEAN.&lt;BR /&gt;Thank you so much!</description>
    <pubDate>Thu, 02 Dec 2021 13:14:47 GMT</pubDate>
    <dc:creator>ikoba</dc:creator>
    <dc:date>2021-12-02T13:14:47Z</dc:date>
    <item>
      <title>PROC REPORT coloring a field based on 2 other fields</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-coloring-a-field-based-on-2-other-fields/m-p/783041#M25486</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a dataset with 5 fields.&lt;/P&gt;&lt;P&gt;study, site, subject, total_q, closed_q&lt;/P&gt;&lt;P&gt;I would like to color the closed_q field based on closed_q/total_q.&lt;/P&gt;&lt;P&gt;I tried this, but it is not works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc report data = sr.drs nowd;
columns study site subject total_q closed_q ;
define study/group ;
define site/group ;
define total_q / analysis style(header)=[background=olive];
define closed_q / analysis style(header)=[background=olive];

compute closed_q;
if round((closed_q/total_q)*100,0.01)&amp;lt;50 then call define (_col_,"style","STYLE=[BACKGROUND=RED]");
else if round((closed_q/total_q)*100,0.01)&amp;gt;=50 and round((closed_q/total_q)*100,0.01)&amp;lt;75 then call define (_col_,"style","STYLE=[BACKGROUND=ROSE]");
else if round((closed_q/total_q)*100,0.01)&amp;gt;=75 and round((closed_q/total_q)*100,0.01)&amp;lt;85 then call define (_col_,"style","STYLE=[BACKGROUND=ORANGE]");
else if round((closed_q/total_q)*100,0.01)&amp;gt;=85 and round((closed_q/total_q)*100,0.01)&amp;lt;95 then call define (_col_,"style","STYLE=[BACKGROUND=YELLOW]");
else if round((closed_q/total_q)*100,0.01)&amp;gt;=95 then call define (_col_,"style","STYLE=[BACKGROUND=GREEN]");
endcomp;

break after site / skip summarize style=[background=CXF2F2F2 font_weight=bold];
break after study / skip summarize style=[background=CXFFFFCC font_weight=bold];
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I tried another solution, I added one more field (pq) to the dataset with the value of&amp;nbsp;closed_q/total_q:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
&amp;nbsp;update sr.drs set pq=round((closed_q/total_q)*100,0.01);
quit;



proc report data = sr.drs nowd;
columns study site subject pq total_q closed_q ;
define study/group ;
define site/group ;

define pq / analysis mean noprint;

define total_q / analysis style(header)=[background=olive];
define closed_q / analysis style(header)=[background=olive];

compute closed_q;
if pq&amp;lt;50 then call define (_col_,"style","STYLE=[BACKGROUND=RED]");
else if pq&amp;gt;=50 and pq&amp;lt;75 then call define (_col_,"style","STYLE=[BACKGROUND=ROSE]");
else if pq&amp;gt;=75 and pq&amp;lt;85 then call define (_col_,"style","STYLE=[BACKGROUND=ORANGE]");
else if pq&amp;gt;=85 and pq&amp;lt;95 then call define (_col_,"style","STYLE=[BACKGROUND=YELLOW]");
else if pq&amp;gt;=95 then call define (_col_,"style","STYLE=[BACKGROUND=GREEN]");
endcomp;

break after site / skip summarize style=[background=CXF2F2F2 font_weight=bold];
break after study / skip summarize style=[background=CXFFFFCC font_weight=bold];
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have the same issue, closed_q column is always red.&lt;/P&gt;&lt;P&gt;Could you please help me what is wrong here?&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 22:42:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-coloring-a-field-based-on-2-other-fields/m-p/783041#M25486</guid>
      <dc:creator>ikoba</dc:creator>
      <dc:date>2021-11-29T22:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT coloring a field based on 2 other fields</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-coloring-a-field-based-on-2-other-fields/m-p/783413#M25490</link>
      <description>Hi:&lt;BR /&gt;  Without data, no one can test or tweak your code. Are there any messages in the log about variables being uninitialized? When you use an analysis variable, such as your PQ variable, you specify the MEAN statistic for the analysis. PROC REPORT has rules about how you must reference analysis variables in a COMPUTE block. You are required to use a compound name such as variable.statistic in the compute block. So for your PQ variable, it appears the correct reference should be PQ.MEAN in the COMPUTE block. You should be seeing a message in the SAS log. For your other variables, CLOSED_Q and TOTAL_Q, you've specified them as analysis variables, which have a default statistic of SUM, so the issue with using those variables is that PROC REPORT would expect the reference in a COMPUTE block to be CLOSED_Q.SUM and TOTAL_Q.SUM -- this is one of the rules of PROC REPORT -- if you search the forums, you should find many other postings on the topic of using compound names in PROC REPORT's COMPUTE block.&lt;BR /&gt;  Also note that changing the color of cells only works in ODS destinations like RTF, PDF, HTML, etc. the use of the SKIP option in the break statement is ignored in ODS destinations. You won't see any messages, you just won't see a skipped line where you expect it. The PROC REPORT documentation shows which options are LISTING-only options such as SKIP, DOL, DUL, OL, UL, LS, PS, FLOW, etc.&lt;BR /&gt;Cynthia</description>
      <pubDate>Wed, 01 Dec 2021 16:27:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-coloring-a-field-based-on-2-other-fields/m-p/783413#M25490</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-12-01T16:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT coloring a field based on 2 other fields</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-coloring-a-field-based-on-2-other-fields/m-p/783605#M25492</link>
      <description>Hi Cynthia,&lt;BR /&gt;Sorry, next time I will add test data and screenshot. The problem was that I missed the .MEAN. I tried with .SUM, but not with .MEAN.&lt;BR /&gt;Thank you so much!</description>
      <pubDate>Thu, 02 Dec 2021 13:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-coloring-a-field-based-on-2-other-fields/m-p/783605#M25492</guid>
      <dc:creator>ikoba</dc:creator>
      <dc:date>2021-12-02T13:14:47Z</dc:date>
    </item>
  </channel>
</rss>

