<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report/m-p/694438#M211777</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to colour cells if their value exceeds UCL1 or UCL2.&lt;/P&gt;
&lt;P&gt;UCL2 is always higher then UCL1.&lt;/P&gt;
&lt;P&gt;If cell value exceeds UCL2 then it is red.&lt;/P&gt;
&lt;P&gt;If cell value exceeds UCL1 and not UCL2 then it is light pink.&lt;/P&gt;
&lt;P&gt;If cell value doesnt exceed UCL1 anddoesnt exceed UCL2 then it is light green.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Why option1 is working well and option2 is not working well?&lt;/P&gt;
&lt;P&gt;I don't understand the difference between them in the code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; Data RedLights;
Input Subject UCL1 UCL2 Val2009 Val2006 Val2003 Val1912;
cards;
1 15 20 10 8 9 18
2 13 14 15 10 9 8
3 70 80 50 45 90 30
4 25 35 30 16 15 12
5 30 40 17 20 25 30
;
run;
 

proc report data=RedLights nowd;
  column Subject UCL1 UCL2 Val2009 Val2006 Val2003 Val1912 last;/*Add dummy last*/
  define Subject / display  'Subject/Number';
  define UCL1 / display  "Upper/Control/Limit #1";
  define UCL2 / display  "Upper/Control/Limit #2";
  define Val2009 / display 'SEP-2020' style(column)=[background=lightgreen];
  define Val2006 / display 'JUN-2020' style(column)=[background=lightgreen];
  define Val2003 / display 'MAR-2020' style(column)=[background=lightgreen];
  define Val1912 / display 'DEC-2019' style(column)=[background=lightgreen];
  define last / noprint;

/*Option1*/
/*compute last;*/
/*array aaa val2009 val2006 val2003 val1912;*/
/*do index = 1 to dim (aaa);*/
/*val = aaa(index);*/
/*vname = vname(aaa(index));*/
/*if val &amp;lt;= UCL1 and val&amp;lt;=UCL2 then call define(trim(vname),"style","style={background=lightgreen}");*/
/*else if val&amp;gt;UCL1 and val&amp;lt;=UCL2 then call define(trim(vname),"style","style={background=lightpink}");*/
/*else call define(trim(vname),"style","style={background=red}");*/
/*end;*/
/*endcomp;*/

/*Option2*/
compute last;
array aaa val2009 val2006 val2003 val1912;
do index = 1 to dim (aaa);
val = aaa(index);
vname = vname(aaa(index));
if val &amp;lt;= UCL1 and val&amp;lt;=UCL2 then call define(trim(vname),"style","style={background=lightgreen}");
else if val&amp;gt;UCL1 and val&amp;lt;=UCL2 then call define(trim(vname),"style","style={background=lightpink}");
else if val&amp;lt;=UCL1 and val&amp;gt;UCL2 then call define(trim(vname),"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>Tue, 27 Oct 2020 06:27:56 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2020-10-27T06:27:56Z</dc:date>
    <item>
      <title>Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report/m-p/694438#M211777</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to colour cells if their value exceeds UCL1 or UCL2.&lt;/P&gt;
&lt;P&gt;UCL2 is always higher then UCL1.&lt;/P&gt;
&lt;P&gt;If cell value exceeds UCL2 then it is red.&lt;/P&gt;
&lt;P&gt;If cell value exceeds UCL1 and not UCL2 then it is light pink.&lt;/P&gt;
&lt;P&gt;If cell value doesnt exceed UCL1 anddoesnt exceed UCL2 then it is light green.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Why option1 is working well and option2 is not working well?&lt;/P&gt;
&lt;P&gt;I don't understand the difference between them in the code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; Data RedLights;
Input Subject UCL1 UCL2 Val2009 Val2006 Val2003 Val1912;
cards;
1 15 20 10 8 9 18
2 13 14 15 10 9 8
3 70 80 50 45 90 30
4 25 35 30 16 15 12
5 30 40 17 20 25 30
;
run;
 

proc report data=RedLights nowd;
  column Subject UCL1 UCL2 Val2009 Val2006 Val2003 Val1912 last;/*Add dummy last*/
  define Subject / display  'Subject/Number';
  define UCL1 / display  "Upper/Control/Limit #1";
  define UCL2 / display  "Upper/Control/Limit #2";
  define Val2009 / display 'SEP-2020' style(column)=[background=lightgreen];
  define Val2006 / display 'JUN-2020' style(column)=[background=lightgreen];
  define Val2003 / display 'MAR-2020' style(column)=[background=lightgreen];
  define Val1912 / display 'DEC-2019' style(column)=[background=lightgreen];
  define last / noprint;

/*Option1*/
/*compute last;*/
/*array aaa val2009 val2006 val2003 val1912;*/
/*do index = 1 to dim (aaa);*/
/*val = aaa(index);*/
/*vname = vname(aaa(index));*/
/*if val &amp;lt;= UCL1 and val&amp;lt;=UCL2 then call define(trim(vname),"style","style={background=lightgreen}");*/
/*else if val&amp;gt;UCL1 and val&amp;lt;=UCL2 then call define(trim(vname),"style","style={background=lightpink}");*/
/*else call define(trim(vname),"style","style={background=red}");*/
/*end;*/
/*endcomp;*/

/*Option2*/
compute last;
array aaa val2009 val2006 val2003 val1912;
do index = 1 to dim (aaa);
val = aaa(index);
vname = vname(aaa(index));
if val &amp;lt;= UCL1 and val&amp;lt;=UCL2 then call define(trim(vname),"style","style={background=lightgreen}");
else if val&amp;gt;UCL1 and val&amp;lt;=UCL2 then call define(trim(vname),"style","style={background=lightpink}");
else if val&amp;lt;=UCL1 and val&amp;gt;UCL2 then call define(trim(vname),"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>Tue, 27 Oct 2020 06:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report/m-p/694438#M211777</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-10-27T06:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report/m-p/694441#M211780</link>
      <description>&lt;P&gt;the last condition looks wrong to me a value can not be greater than and small than at a same time.Check your last condition .&lt;/P&gt;&lt;PRE class="language-sas"&gt;&lt;CODE&gt;else if val&amp;lt;=UCL1 and val&amp;gt;UCL2 then call define(trim(vname),"style","style={background=red}");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 08:08:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report/m-p/694441#M211780</guid>
      <dc:creator>shweta_d_singh</dc:creator>
      <dc:date>2020-10-27T08:08:39Z</dc:date>
    </item>
  </channel>
</rss>

