<?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 by condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-report-color-by-condition/m-p/809684#M319303</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I want to ask you 2 questions about the same topic:&lt;/P&gt;&lt;P&gt;1. Some explanation. Avg_s1 &amp;amp;&amp;nbsp; Avg_s4&amp;nbsp;is simple average.Avg_n_s1 is average + number of observation in parenthesis, this is a character variable, for example, 3.5(24). I want to color this variable based on numeric variables&amp;nbsp;Avg_s1 &amp;amp;&amp;nbsp; Avg_s4. And i don't want to display in the report&amp;nbsp;Avg_s1 &amp;amp;&amp;nbsp; Avg_s4.&lt;/P&gt;&lt;P&gt;In the following code, when i change display to noprint option for&amp;nbsp;Avg_s1 &amp;amp;&amp;nbsp; Avg_s4 i don't get any color.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sort data=report1_stat; by stn; run;

proc report data=report1_stat;
column stn  AVG_S4=AVG_S4_ALIAS AVG_S1 &lt;SPAN&gt;AVG_S4 &lt;/SPAN&gt;avg_n_s1;
define stn / order;
define AVG_S4_ALIAS / noprint;
define AVG_S1 / display;&lt;BR /&gt;&lt;SPAN&gt;define AVG_S4 / display;&lt;/SPAN&gt;
define avg_n_s1 / display &amp;amp;smpl1_label;
compute avg_n_s1;
if (AVG_S1/AVG_S4_ALIAS-1)&amp;gt;0.2 and  AVG_S4_ALIAS~=. then do;
   call define('avg_n_s1', "style", "style=[background=lightred]");
end;
if (AVG_S4_ALIAS/AVG_S1-1)&amp;gt;0.2 and  AVG_S4_ALIAS~=. then do;
   call define('avg_n_s1', "style", "style=[background=lightgreen]");
end;
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Suppose i have the following data, that consist of last 12 monthes and avertage for whole year, of course the months change dynamically during period. My question is how can i color months average values by condition, for example, if average month is higher by 20% from whole year average. Because i don't know exactly variable names.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;type&lt;/TD&gt;&lt;TD&gt;AVG&lt;/TD&gt;&lt;TD&gt;MAR22&lt;/TD&gt;&lt;TD&gt;FEB22&lt;/TD&gt;&lt;TD&gt;JAN22&lt;/TD&gt;&lt;TD&gt;DEC21&lt;/TD&gt;&lt;TD&gt;NOV21&lt;/TD&gt;&lt;TD&gt;OCT21&lt;/TD&gt;&lt;TD&gt;SEP21&lt;/TD&gt;&lt;TD&gt;AUG21&lt;/TD&gt;&lt;TD&gt;JUL21&lt;/TD&gt;&lt;TD&gt;JUN21&lt;/TD&gt;&lt;TD&gt;MAY21&lt;/TD&gt;&lt;TD&gt;APR21&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;9.49&lt;/TD&gt;&lt;TD&gt;5.47&lt;/TD&gt;&lt;TD&gt;9.25&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;9.85&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;9.12&lt;/TD&gt;&lt;TD&gt;6.36&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;17&lt;/TD&gt;&lt;TD&gt;9.83&lt;/TD&gt;&lt;TD&gt;7.35&lt;/TD&gt;&lt;TD&gt;6.44&lt;/TD&gt;&lt;TD&gt;11.17&lt;/TD&gt;&lt;TD&gt;8.56&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THANK YOU!!!&lt;/P&gt;</description>
    <pubDate>Mon, 25 Apr 2022 13:10:24 GMT</pubDate>
    <dc:creator>AlexeyS</dc:creator>
    <dc:date>2022-04-25T13:10:24Z</dc:date>
    <item>
      <title>proc report : color by condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-color-by-condition/m-p/809684#M319303</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I want to ask you 2 questions about the same topic:&lt;/P&gt;&lt;P&gt;1. Some explanation. Avg_s1 &amp;amp;&amp;nbsp; Avg_s4&amp;nbsp;is simple average.Avg_n_s1 is average + number of observation in parenthesis, this is a character variable, for example, 3.5(24). I want to color this variable based on numeric variables&amp;nbsp;Avg_s1 &amp;amp;&amp;nbsp; Avg_s4. And i don't want to display in the report&amp;nbsp;Avg_s1 &amp;amp;&amp;nbsp; Avg_s4.&lt;/P&gt;&lt;P&gt;In the following code, when i change display to noprint option for&amp;nbsp;Avg_s1 &amp;amp;&amp;nbsp; Avg_s4 i don't get any color.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sort data=report1_stat; by stn; run;

proc report data=report1_stat;
column stn  AVG_S4=AVG_S4_ALIAS AVG_S1 &lt;SPAN&gt;AVG_S4 &lt;/SPAN&gt;avg_n_s1;
define stn / order;
define AVG_S4_ALIAS / noprint;
define AVG_S1 / display;&lt;BR /&gt;&lt;SPAN&gt;define AVG_S4 / display;&lt;/SPAN&gt;
define avg_n_s1 / display &amp;amp;smpl1_label;
compute avg_n_s1;
if (AVG_S1/AVG_S4_ALIAS-1)&amp;gt;0.2 and  AVG_S4_ALIAS~=. then do;
   call define('avg_n_s1', "style", "style=[background=lightred]");
end;
if (AVG_S4_ALIAS/AVG_S1-1)&amp;gt;0.2 and  AVG_S4_ALIAS~=. then do;
   call define('avg_n_s1', "style", "style=[background=lightgreen]");
end;
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Suppose i have the following data, that consist of last 12 monthes and avertage for whole year, of course the months change dynamically during period. My question is how can i color months average values by condition, for example, if average month is higher by 20% from whole year average. Because i don't know exactly variable names.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;type&lt;/TD&gt;&lt;TD&gt;AVG&lt;/TD&gt;&lt;TD&gt;MAR22&lt;/TD&gt;&lt;TD&gt;FEB22&lt;/TD&gt;&lt;TD&gt;JAN22&lt;/TD&gt;&lt;TD&gt;DEC21&lt;/TD&gt;&lt;TD&gt;NOV21&lt;/TD&gt;&lt;TD&gt;OCT21&lt;/TD&gt;&lt;TD&gt;SEP21&lt;/TD&gt;&lt;TD&gt;AUG21&lt;/TD&gt;&lt;TD&gt;JUL21&lt;/TD&gt;&lt;TD&gt;JUN21&lt;/TD&gt;&lt;TD&gt;MAY21&lt;/TD&gt;&lt;TD&gt;APR21&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;9.49&lt;/TD&gt;&lt;TD&gt;5.47&lt;/TD&gt;&lt;TD&gt;9.25&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;9.85&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;9.12&lt;/TD&gt;&lt;TD&gt;6.36&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;17&lt;/TD&gt;&lt;TD&gt;9.83&lt;/TD&gt;&lt;TD&gt;7.35&lt;/TD&gt;&lt;TD&gt;6.44&lt;/TD&gt;&lt;TD&gt;11.17&lt;/TD&gt;&lt;TD&gt;8.56&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THANK YOU!!!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 13:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-color-by-condition/m-p/809684#M319303</guid>
      <dc:creator>AlexeyS</dc:creator>
      <dc:date>2022-04-25T13:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: proc report : color by condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-color-by-condition/m-p/809825#M319372</link>
      <description>&lt;P&gt;1. Give us some sample data to play with.&lt;/P&gt;
&lt;P&gt;2. What code do you&amp;nbsp; write if you don't know the variable names?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 08:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-color-by-condition/m-p/809825#M319372</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2022-04-26T08:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: proc report : color by condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-color-by-condition/m-p/809839#M319374</link>
      <description>&lt;P&gt;1. DATA for question 1&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;STN&lt;/TD&gt;&lt;TD&gt;AVG_S1&lt;/TD&gt;&lt;TD&gt;AVG_S2&lt;/TD&gt;&lt;TD&gt;AVG_S4&lt;/TD&gt;&lt;TD&gt;AVG_N_S1&lt;/TD&gt;&lt;TD&gt;AVG_N_S2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;3.2&lt;/TD&gt;&lt;TD&gt;4.2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3.2(5)&lt;/TD&gt;&lt;TD&gt;4.2(10)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;2.1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;3.5&lt;/TD&gt;&lt;TD&gt;2.1(4)&lt;/TD&gt;&lt;TD&gt;1*(40)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3.1&lt;/TD&gt;&lt;TD&gt;2.2&lt;/TD&gt;&lt;TD&gt;3(15)&lt;/TD&gt;&lt;TD&gt;3.1(58)&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Now the code is working, but when i change option of AVG_S1 &amp;amp; AVG_S2 from dispay to noprint, because i dont want to see in the final report these variable, the color is disappearing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.Every month i run code, and i create a report for one year ago, so each time the names of variables MONYY can be changed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THANK YOU&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 10:29:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-color-by-condition/m-p/809839#M319374</guid>
      <dc:creator>AlexeyS</dc:creator>
      <dc:date>2022-04-26T10:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: proc report : color by condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-color-by-condition/m-p/810051#M319435</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; The challenge is that you NEED for the usage to be display, even with NOPRINT for those variables because without DISPLAY, the numeric variables will be treated as ANALYSIS variables with a statistic of SUM, which would change how you need to code them, using the&lt;EM&gt;&lt;STRONG&gt; variable.statisti&lt;/STRONG&gt;&lt;STRONG&gt;c&lt;/STRONG&gt; &lt;/EM&gt;syntax. With a usage of DISPLAY, that is what allows you to just use the variable name in the COMPUTE block. See below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1651016885667.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70893i15CF92518355F349/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1651016885667.png" alt="Cynthia_sas_0-1651016885667.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; You don't need the DISPLAY for the aliased column because the rule for aliased columns is that you can use the alias name as a reference in the COMPUTE block.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 23:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-color-by-condition/m-p/810051#M319435</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2022-04-26T23:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: proc report : color by condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-color-by-condition/m-p/810069#M319444</link>
      <description>&lt;P&gt;You don't reply to either question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Data is expected to be given as code so we can use it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. No additional information provided.&lt;/P&gt;
&lt;P&gt;Each time users ask a question like yours, the answer is always the same: Your data should be vertical. A database is not Excel. Like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
TYPE='A';
DATE='01MAR2022'd;AMT= 5.47; output;
DATE='01FEB2022'd;AMT= 9.25; output;		
DATE='01JAN2022'd;AMT= 9.85; output; 	
DATE='01DEC2021'd;AMT= 9.12; output;		
DATE='01NOV2021'd;AMT= 6.36; output;		
DATE='01OCT2021'd;AMT=10.00; output;	
DATE='01SEP2021'd;AMT=17.00; output;	
DATE='01AUG2021'd;AMT= 9.83; output;		
DATE='01JUL2021'd;AMT= 7.35; output;		
DATE='01JUN2021'd;AMT= 6.44; output;		
DATE='01MAY2021'd;AMT=11.17; output;	
DATE='01APR2021'd;AMT= 8.56; output;
DATE='01MAR2021'd;AMT= 8.56; output;
DATE='01FEB2021'd;AMT= 8.56; output;
DATE='01JAN2021'd;AMT= 8.56; output;
format date monyy5.;
proc tabulate data=HAVE ;
  where DATE &amp;gt; '01MAR2021'd;
  class TYPE DATE;
  var AMT;
  table TYPE=' ',DATE=' '*AMT=' '*sum=' ';
run;   
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV&gt;
&lt;DIV id="IDX"&gt;
&lt;DIV&gt;
&lt;TABLE class="table" aria-label="Table 1"&gt;&lt;CAPTION aria-label="Table 1"&gt;&amp;nbsp;&lt;/CAPTION&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c m header" scope="col" width="9.875px"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="c header" scope="col" width="43px"&gt;APR21&lt;/TH&gt;
&lt;TH class="c header" scope="col" width="50.1875px"&gt;MAY21&lt;/TH&gt;
&lt;TH class="c header" scope="col" width="43px"&gt;JUN21&lt;/TH&gt;
&lt;TH class="c header" scope="col" width="43px"&gt;JUL21&lt;/TH&gt;
&lt;TH class="c header" scope="col" width="44px"&gt;AUG21&lt;/TH&gt;
&lt;TH class="c header" scope="col" width="51.375px"&gt;SEP21&lt;/TH&gt;
&lt;TH class="c header" scope="col" width="52px"&gt;OCT21&lt;/TH&gt;
&lt;TH class="c header" scope="col" width="44px"&gt;NOV21&lt;/TH&gt;
&lt;TH class="c header" scope="col" width="43px"&gt;DEC21&lt;/TH&gt;
&lt;TH class="c header" scope="col" width="42.4792px"&gt;JAN22&lt;/TH&gt;
&lt;TH class="c header" scope="col" width="43px"&gt;FEB22&lt;/TH&gt;
&lt;TH class="c header" scope="col" width="45px"&gt;MAR22&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="t rowheader" scope="row" width="9.875px"&gt;A&lt;/TH&gt;
&lt;TD width="43px" class="r b data"&gt;8.56&lt;/TD&gt;
&lt;TD width="50.1875px" class="r b data"&gt;11.17&lt;/TD&gt;
&lt;TD width="43px" class="r b data"&gt;6.44&lt;/TD&gt;
&lt;TD width="43px" class="r b data"&gt;7.35&lt;/TD&gt;
&lt;TD width="44px" class="r b data"&gt;9.83&lt;/TD&gt;
&lt;TD width="51.375px" class="r b data"&gt;17.00&lt;/TD&gt;
&lt;TD width="52px" class="r b data"&gt;10.00&lt;/TD&gt;
&lt;TD width="44px" class="r b data"&gt;6.36&lt;/TD&gt;
&lt;TD width="43px" class="r b data"&gt;9.12&lt;/TD&gt;
&lt;TD width="42.4792px" class="r b data"&gt;9.85&lt;/TD&gt;
&lt;TD width="43px" class="r b data"&gt;9.25&lt;/TD&gt;
&lt;TD width="45px" class="r b data"&gt;5.47&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 05:59:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-color-by-condition/m-p/810069#M319444</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2022-04-27T05:59:28Z</dc:date>
    </item>
  </channel>
</rss>

