<?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: How to color the row in proc report depending on subcolumn values in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-color-the-row-in-proc-report-depending-on-subcolumn/m-p/310262#M17343</link>
    <description>&lt;P&gt;Hi Chris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd generally recommend using OUT to create an output dataset during development. That way you can see the values&amp;nbsp;created within the Proc Report step -&amp;nbsp;sometimes its difficult to understand what is actually happenning in the procedure and having access to this information is useful during development.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code should give you what your looking for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc report data=LINED nowd out=work.test;
  column ROW LINE COL,(VALUE COUNT);
  define ROW   /group;
  define LINE  /group noprint;
  define COL   /across ' ';
  define VALUE /display  ;
  define COUNT /analysis '#' ;
  compute LINE;
     if LINE &amp;gt; 1 then call define(_row_,"style","style={background=cxEEFFFF}");
    * if COUNT=3  then call define(_row_,"style","style={background=cxEEFFFF}");
    * if _C5_=3 | _C3_=3 then call define(_row_,"style","style={background=cxEEFFFF}");
  endcomp;

  compute COL;
    if _C4_ = 3 or _C6_=3  then call define(_row_,"style","style={background=cxEEFFFF}");
  endcomp;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Nov 2016 02:45:49 GMT</pubDate>
    <dc:creator>Dan_B</dc:creator>
    <dc:date>2016-11-09T02:45:49Z</dc:date>
    <item>
      <title>How to color the row in proc report depending on subcolumn values</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-color-the-row-in-proc-report-depending-on-subcolumn/m-p/310257#M17342</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have coloured the second line (because it is not the first line for row R1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also want to colour the third line (because a count is equal to 3).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5719iB932465AA93CF4AC/image-size/original?v=v2&amp;amp;px=-1" alt="aaa1.PNG" title="aaa1.PNG" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any idea how? My attempts (commented out below) fail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data HAVE;
  input ROW $ COL $ VALUE $ ;
cards;
R1 C1 x
R1 C2 y
R1 C1 x1
R1 C2 y
R2 C1 x
R2 C2 z
R2 C1 x
R2 C2 z
R2 C2 z
run;

proc freq data=HAVE noprint;
  table ROW*COL*VALUE/out=FREQ  ;
run;

data LINED;  
  set FREQ;
  by ROW COL;
  if first.COL then LINE=0;
  LINE+1;
run;

proc sort; 
  by ROW LINE COL;
run;

proc report data=LINED nowd ;
  column ROW LINE COL,(VALUE COUNT);
  define ROW   /group;
  define LINE  /group noprint;
  define COL   /across ' ';
  define VALUE /display  ;
  define COUNT /analysis '#' ;
  compute LINE;
     if LINE &amp;gt; 1 then call define(_row_,"style","style={background=cxEEFFFF}");
    * if COUNT=3  then call define(_row_,"style","style={background=cxEEFFFF}");
    * if _C5_=3 | _C3_=3 then call define(_row_,"style","style={background=cxEEFFFF}");
  endcomp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 01:31:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-color-the-row-in-proc-report-depending-on-subcolumn/m-p/310257#M17342</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-11-09T01:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to color the row in proc report depending on subcolumn values</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-color-the-row-in-proc-report-depending-on-subcolumn/m-p/310262#M17343</link>
      <description>&lt;P&gt;Hi Chris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd generally recommend using OUT to create an output dataset during development. That way you can see the values&amp;nbsp;created within the Proc Report step -&amp;nbsp;sometimes its difficult to understand what is actually happenning in the procedure and having access to this information is useful during development.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code should give you what your looking for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc report data=LINED nowd out=work.test;
  column ROW LINE COL,(VALUE COUNT);
  define ROW   /group;
  define LINE  /group noprint;
  define COL   /across ' ';
  define VALUE /display  ;
  define COUNT /analysis '#' ;
  compute LINE;
     if LINE &amp;gt; 1 then call define(_row_,"style","style={background=cxEEFFFF}");
    * if COUNT=3  then call define(_row_,"style","style={background=cxEEFFFF}");
    * if _C5_=3 | _C3_=3 then call define(_row_,"style","style={background=cxEEFFFF}");
  endcomp;

  compute COL;
    if _C4_ = 3 or _C6_=3  then call define(_row_,"style","style={background=cxEEFFFF}");
  endcomp;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 02:45:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-color-the-row-in-proc-report-depending-on-subcolumn/m-p/310262#M17343</guid>
      <dc:creator>Dan_B</dc:creator>
      <dc:date>2016-11-09T02:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to color the row in proc report depending on subcolumn values</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-color-the-row-in-proc-report-depending-on-subcolumn/m-p/310265#M17344</link>
      <description>&lt;P&gt;Thanks for the&amp;nbsp; &lt;FONT face="courier new,courier"&gt;out=&lt;/FONT&gt;&amp;nbsp; tip!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2 things:&lt;/P&gt;
&lt;P&gt;-&amp;nbsp; why do we need to have column COL as the computed value?&lt;/P&gt;
&lt;P&gt;- something seems wrong with inequalities:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc report data=LINED nowd out=t;
  column ROW LINE COL,(VALUE COUNT);
  define ROW   /group;
  define LINE  /group noprint;
  define COL   /across ' ';
  define VALUE /display  ;
  define COUNT /analysis '#' ;
  compute LINE;
     if LINE &amp;gt; 1 then call define(_row_,"style","style={background=cxEEFFFF}");
  endcomp;
  compute COL;
     * 3rd line is blue as intended;
     * if _C4_ = 2 then call define(_row_,"style","style={background=cxEEFFFF}");
     * 1st line is blue as intended;
     * if _C4_ = 1 then call define(_row_,"style","style={background=cxEEFFFF}");
     * all lines are blue! not intended ! ;
     * if _C4_ ^in (1,2) then call define(_row_,"style","style={background=cxEEFFFF}");
  endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 03:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-color-the-row-in-proc-report-depending-on-subcolumn/m-p/310265#M17344</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-11-09T03:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to color the row in proc report depending on subcolumn values</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-color-the-row-in-proc-report-depending-on-subcolumn/m-p/310275#M17346</link>
      <description>&lt;P&gt;The timing and execution of&amp;nbsp;the compute blocks can be quite different based on the association of report items. In this scenario you may want the compute block to execute when the proc report processes the COUNT column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are some good papers that go into quite a bit of detail to explain the sequence of compute blocks. From memory they work from left to right in order of columns (not by the order of your compute block codes).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once I adjusted the compute block to execute when processing the COUNT column the issue with the IN operator is corrected. You could combine the LINE compute block with the COUNT compute block since LINE column would already be processed by this stage.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc report data=LINED nowd out=t;
  column ROW LINE COL,(VALUE COUNT);
  define ROW   /group;
  define LINE  /group noprint;
  define COL   /across ' ';
  define VALUE /display  ;
  define COUNT /analysis '#' ;
/*  compute LINE;*/
/*     if LINE &amp;gt; 1 then call define(_row_,"style","style={background=cxEEFFFF}");*/
/*  endcomp;*/
  compute COUNT;
     if LINE &amp;gt; 1 then call define(_row_,"style","style={background=cxEEFFFF}");
     * 3rd line is blue as intended;
     * if _C4_ = 2 then call define(_row_,"style","style={background=cxEEFFFF}");
     * 1st line is blue as intended;
     * if _C4_ = 1 then call define(_row_,"style","style={background=cxEEFFFF}");
     * all lines are blue! not intended ! ; 
     * Corrected by adjusting the COMPUTE block to execute when processing of COUNT;
      if _C4_ ^in (1,2) then call define(_row_,"style","style={background=cxEEFFFF}");
  endcomp;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Nov 2016 04:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-color-the-row-in-proc-report-depending-on-subcolumn/m-p/310275#M17346</guid>
      <dc:creator>Dan_B</dc:creator>
      <dc:date>2016-11-09T04:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to color the row in proc report depending on subcolumn values</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-color-the-row-in-proc-report-depending-on-subcolumn/m-p/310283#M17347</link>
      <description>&lt;PRE&gt;

Put that in the right column.




data HAVE;
  input ROW $ COL $ VALUE $ ;
cards;
R1 C1 x
R1 C2 y
R1 C1 x1
R1 C2 y
R2 C1 x
R2 C2 z
R2 C1 x
R2 C2 z
R2 C2 z
run;

proc freq data=HAVE noprint;
  table ROW*COL*VALUE/out=FREQ  ;
run;

data LINED;  
  set FREQ;
  by ROW COL;
  if first.COL then LINE=0;
  LINE+1;
run;

proc sort; 
  by ROW LINE COL;
run;

proc report data=LINED nowd ;
  column ROW LINE COL,(VALUE COUNT);
  define ROW   /group;
  define LINE  /group noprint;
  define COL   /across ' ';
  define VALUE /display  ;
  define COUNT /analysis '#' ;
  compute LINE;
     if LINE &amp;gt; 1 then call define(_row_,"style","style={background=cxEEFFFF}");
  endcomp;
  compute count;
     if _C6_=3 | _C3_=3 then call define(_row_,"style","style={background=cxEEFFFF}");
  endcomp;
run;
&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Nov 2016 05:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-color-the-row-in-proc-report-depending-on-subcolumn/m-p/310283#M17347</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-11-09T05:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to color the row in proc report depending on subcolumn values</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-color-the-row-in-proc-report-depending-on-subcolumn/m-p/310546#M17348</link>
      <description>&lt;P&gt;Thank you all.&lt;/P&gt;
&lt;P&gt;These proc report compute blocks sure are tricky to get right.&lt;/P&gt;
&lt;P&gt;All good now i think!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2016 00:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-to-color-the-row-in-proc-report-depending-on-subcolumn/m-p/310546#M17348</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-11-10T00:46:19Z</dc:date>
    </item>
  </channel>
</rss>

