<?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 - conditional formatting based on group value in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-report-conditional-formatting-based-on-group-value/m-p/597441#M76243</link>
    <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; You can also do this directly in PROC REPORT by using a temporary variable. This saves you the overhead of making a copy of the report data:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;proc report data=sashelp.cars;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; columns Origin Make Model;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; define Origin / group;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; define Make / display;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; define Model / display;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &lt;FONT color="#FF00FF"&gt;compute before origin;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length hold_or $6;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hold_or=origin;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; endcomp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; compute Model;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if &lt;FONT color="#FF00FF"&gt;hold_or&lt;/FONT&gt; EQ "Asia" then&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call define (_col_,"style","style={background=red}");&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; endcomp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the above instance the HOLD_OR item is a temporary item that is created at the beginning of each group on the first row, when Origin has a value. Temporary items in PROC REPORT are automatically retained (do NOT put the temporary item in the COLUMN statement or you will lose this benefit). That means HOLD_OR is available to be tested (instead of Origin) in the COMPUTE block for Model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Oct 2019 17:03:42 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2019-10-17T17:03:42Z</dc:date>
    <item>
      <title>proc report - conditional formatting based on group value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-report-conditional-formatting-based-on-group-value/m-p/597339#M76240</link>
      <description>&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to conditionally format my report based on the group value. Unfortunately, the formatting only gets applied to the first cell/row in the group, the one in which group value is displayed:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sashelp.cars;
	columns Origin Make Model;
	define Origin / group;
	define Make -- Model / display;

	compute Model;

		if Origin EQ "Asia" then
			call define (_col_,"style","style={background=red}");
	endcomp;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there a way of applying a conditional format to all elements in a particular group? Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 14:26:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-report-conditional-formatting-based-on-group-value/m-p/597339#M76240</guid>
      <dc:creator>js5</dc:creator>
      <dc:date>2019-10-17T14:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: proc report - conditional formatting based on group value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-report-conditional-formatting-based-on-group-value/m-p/597362#M76242</link>
      <description>&lt;P&gt;You may be having issues because of your code. Note that you will get this note in the Log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;NOTE: Groups are not created because the usage of Make is DISPLAY. To avoid this note, change all
GROUP variables to ORDER variables.
&lt;/PRE&gt;
&lt;P&gt;So the "group" is not created and your attempt to apply a style based on the "group" can't happen the way you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is one way by providing a non-printed variable that would exist on all the display rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data work.cars;
   set sashelp.cars;
   neworigin=origin;
run;

proc report data=work.cars;
	columns Origin neworigin Make Model;
	define Origin / Order;
   define neworigin/noprint;
	define Make -- Model / display;

	compute Model;

		if newOrigin EQ "Asia" then
			call define ('model',"style/replace","style={background=red}");
	endcomp;
quit;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Oct 2019 14:53:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-report-conditional-formatting-based-on-group-value/m-p/597362#M76242</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-10-17T14:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: proc report - conditional formatting based on group value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-report-conditional-formatting-based-on-group-value/m-p/597441#M76243</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; You can also do this directly in PROC REPORT by using a temporary variable. This saves you the overhead of making a copy of the report data:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;proc report data=sashelp.cars;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; columns Origin Make Model;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; define Origin / group;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; define Make / display;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; define Model / display;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &lt;FONT color="#FF00FF"&gt;compute before origin;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length hold_or $6;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hold_or=origin;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; endcomp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; compute Model;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if &lt;FONT color="#FF00FF"&gt;hold_or&lt;/FONT&gt; EQ "Asia" then&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call define (_col_,"style","style={background=red}");&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; endcomp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the above instance the HOLD_OR item is a temporary item that is created at the beginning of each group on the first row, when Origin has a value. Temporary items in PROC REPORT are automatically retained (do NOT put the temporary item in the COLUMN statement or you will lose this benefit). That means HOLD_OR is available to be tested (instead of Origin) in the COMPUTE block for Model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 17:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-report-conditional-formatting-based-on-group-value/m-p/597441#M76243</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-10-17T17:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: proc report - conditional formatting based on group value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-report-conditional-formatting-based-on-group-value/m-p/597639#M76245</link>
      <description>&lt;P&gt;Thank you both! I tried&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;'s solution and it worked perfectly.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2019 08:00:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-report-conditional-formatting-based-on-group-value/m-p/597639#M76245</guid>
      <dc:creator>js5</dc:creator>
      <dc:date>2019-10-18T08:00:32Z</dc:date>
    </item>
  </channel>
</rss>

