<?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: Highlighting Greater Value in Red in PROC REPORT in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Highlighting-Greater-Value-in-Red-in-PROC-REPORT/m-p/931534#M44869</link>
    <description>&lt;P&gt;You might have noticed, that the id value is only in the first row (when a new id value starts), after that it is not visiable and therefor the id variable is empty. You need to put the value of the first row for each id value aside and use this in the compute block. To put the value aside, use a COMPUTE BEFORE columnName compute block. See the example below. I use the _dummy variable to display the contents of the idkeep variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc report data=sample nowd;
  column  id value1 value2 _dummy;
  define id / 'ID' display order order=data;
  
  define value1 / sum 'Value 1';
  define value2 / sum 'Value 2';
  define _dummy / computed;

  compute before id;
    idkeep = id;
  endcomp;

  compute _dummy;
    _dummy = idkeep;
  
    if idkeep = 1 and value1.sum &amp;gt; value2.sum then do;
      call define("value1.sum", "style", "style={background=Red}");
    end;
  endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 10 Jun 2024 11:07:28 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2024-06-10T11:07:28Z</dc:date>
    <item>
      <title>Highlighting Greater Value in Red in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Highlighting-Greater-Value-in-Red-in-PROC-REPORT/m-p/931488#M44866</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;I'm working on a PROC REPORT in SAS and need some help with conditional formatting. Specifically, I want to compare two columns, &lt;CODE&gt;value1&lt;/CODE&gt; and &lt;CODE&gt;value2&lt;/CODE&gt;, and highlight the greater value in red. Below is a simplified version of my dataset and the PROC REPORT code I've tried:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  input id value1 value2;
  datalines;
1 10 15
2 20 5
3 25 30
4 40 35
5 50 50
;
run;


proc report data=sample nowd;
  column id value1 value2;

  define id / 'ID' order=data;
  define value1 / sum 'Value 1' display;
  define value2 / sum 'Value 2' display;

  compute value1;
    if value1 &amp;gt; value2 then do;
      call define(_col_, "style", "style={foreground=Red}");
    end;
  endcomp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want Output&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Daily1_0-1718000621968.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/97153iAF1FEE9B1649CF1B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Daily1_0-1718000621968.png" alt="Daily1_0-1718000621968.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2024 06:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Highlighting-Greater-Value-in-Red-in-PROC-REPORT/m-p/931488#M44866</guid>
      <dc:creator>Daily1</dc:creator>
      <dc:date>2024-06-10T06:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Highlighting Greater Value in Red in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Highlighting-Greater-Value-in-Red-in-PROC-REPORT/m-p/931496#M44867</link>
      <description>&lt;P&gt;Made some changes to the Proc REPORT code, see below. Here are the details for the changes:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Added a _dummy column as the last column. In a compute block for a given column you can only access the values of the columns to the left of the current column. So by adding the _dummy column, I can access all the column values to the left in the _dummy compute block. The value of the _dummy column is not printed (NOPRINT)&lt;/LI&gt;
&lt;LI&gt;added ORDER to the ID variable to display each value&lt;/LI&gt;
&lt;LI&gt;Since value1 and value2 are analysis variables you need to access the value using columnName.statistic in our case value1.sum or value2.sum&lt;/LI&gt;
&lt;LI&gt;This name can also be used in the call define to reference the proper column&lt;/LI&gt;
&lt;LI&gt;change foreground to background in the call define&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sample nowd;
  column id value1 value2 _dummy;

  define id / 'ID'  order order=data;
  define value1 / sum 'Value 1' ;
  define value2 / sum 'Value 2' ;
  define _dummy / computed noprint;

  compute _dummy;
    if value1.sum &amp;gt; value2.sum then do;
      call define("value1.sum", "style", "style={background=Red}");
    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>Mon, 10 Jun 2024 07:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Highlighting-Greater-Value-in-Red-in-PROC-REPORT/m-p/931496#M44867</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2024-06-10T07:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Highlighting Greater Value in Red in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Highlighting-Greater-Value-in-Red-in-PROC-REPORT/m-p/931524#M44868</link>
      <description>&lt;P&gt;Thank you for your help. I have some addition query .&lt;/P&gt;
&lt;P&gt;This code highlights the greater value in red, but only when the ID equals 1. Is it not working properly?&lt;/P&gt;
&lt;P&gt;Revised Data&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  input id value1 value2;
  datalines;
1 10 15
1 20 5
3 25 30
1 40 35
5 50 50
1 10 15
1 20 5
3 25 30
1 40 35
5 50 50
1 10 15
1 20 5
3 40 30
1 40 35
5 55 50
;
run;

proc report data=sample nowd;
  column id value1 value2 _dummy;

  define id / 'ID'  order order=data;
  define value1 / sum 'Value 1';
  define value2 / sum 'Value 2';
  define _dummy / computed noprint;

  compute _dummy;
 if id = 1 and  value1.sum &amp;gt; value2.sum then do;
      call define("value1.sum", "style", "style={background=Red}");
    end;
  endcomp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Jun 2024 09:55:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Highlighting-Greater-Value-in-Red-in-PROC-REPORT/m-p/931524#M44868</guid>
      <dc:creator>Daily1</dc:creator>
      <dc:date>2024-06-10T09:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: Highlighting Greater Value in Red in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Highlighting-Greater-Value-in-Red-in-PROC-REPORT/m-p/931534#M44869</link>
      <description>&lt;P&gt;You might have noticed, that the id value is only in the first row (when a new id value starts), after that it is not visiable and therefor the id variable is empty. You need to put the value of the first row for each id value aside and use this in the compute block. To put the value aside, use a COMPUTE BEFORE columnName compute block. See the example below. I use the _dummy variable to display the contents of the idkeep variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc report data=sample nowd;
  column  id value1 value2 _dummy;
  define id / 'ID' display order order=data;
  
  define value1 / sum 'Value 1';
  define value2 / sum 'Value 2';
  define _dummy / computed;

  compute before id;
    idkeep = id;
  endcomp;

  compute _dummy;
    _dummy = idkeep;
  
    if idkeep = 1 and value1.sum &amp;gt; value2.sum then do;
      call define("value1.sum", "style", "style={background=Red}");
    end;
  endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Jun 2024 11:07:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Highlighting-Greater-Value-in-Red-in-PROC-REPORT/m-p/931534#M44869</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2024-06-10T11:07:28Z</dc:date>
    </item>
  </channel>
</rss>

