<?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: Alternate Group Colors based on Group Var in Proc Report in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Alternate-Group-Colors-based-on-Group-Var-in-Proc-Report/m-p/15779#M3408</link>
    <description>Thanks!&lt;BR /&gt;
&lt;BR /&gt;
I wanted 'banding' so I used a combination of methods, adding some things in my datastep and then in the proc report, the code provided definitely helped in getting there!</description>
    <pubDate>Mon, 20 Jun 2011 16:40:23 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2011-06-20T16:40:23Z</dc:date>
    <item>
      <title>Alternate Group Colors based on Group Var in Proc Report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Alternate-Group-Colors-based-on-Group-Var-in-Proc-Report/m-p/15775#M3404</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I know I've seen this on here before but can't seem to find it at all. &lt;BR /&gt;
&lt;BR /&gt;
I'm using proc report to output some data and would like to alternate the background of the row colors based on the groups, so each group is differentiable from each other. I know I need to use a compute block and call define my style but not sure of the logic to get each group a different colour. &lt;BR /&gt;
&lt;BR /&gt;
Pointers in the right direction are appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;
&lt;BR /&gt;
Sample&lt;BR /&gt;
&lt;BR /&gt;
ID Value Colour&lt;BR /&gt;
1 2 white&lt;BR /&gt;
1 3 white&lt;BR /&gt;
2 3 lightgrey&lt;BR /&gt;
2 4 lightgrey&lt;BR /&gt;
6 3 white&lt;BR /&gt;
8 2 lightgrey&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: Reeza

null</description>
      <pubDate>Fri, 17 Jun 2011 00:12:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Alternate-Group-Colors-based-on-Group-Var-in-Proc-Report/m-p/15775#M3404</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2011-06-17T00:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: Alternate Group Colors based on Group Var in Proc Report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Alternate-Group-Colors-based-on-Group-Var-in-Proc-Report/m-p/15776#M3405</link>
      <description>Hi,&lt;BR /&gt;
If I understood you correctly, the followig can be the solution&lt;BR /&gt;
&lt;BR /&gt;
proc report data=xyz;&lt;BR /&gt;
column a b ;&lt;BR /&gt;
define a/"a" style(column)=[backgroundcolor=maroon foreground=white];&lt;BR /&gt;
define b/"b" style(column)=[backgroundcolor=red foreground=white];&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
And alternative method could be using the call define style option in the computed column.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
ex:&lt;BR /&gt;
proc report data=xyz;&lt;BR /&gt;
column a b ;&lt;BR /&gt;
define a/"a" style(column)=[backgroundcolor=maroon foreground=white];&lt;BR /&gt;
&lt;BR /&gt;
compute a;&lt;BR /&gt;
if a="some value" then do;&lt;BR /&gt;
call define(_col_,"style","style=[backgroundcolor=maroon foreground=white]");&lt;BR /&gt;
end;&lt;BR /&gt;
endcomp;&lt;BR /&gt;
&lt;BR /&gt;
** you can use some condition to format your output;&lt;BR /&gt;
**using proc format to customise 'style' options are also reliable;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Cheers..!!</description>
      <pubDate>Fri, 17 Jun 2011 09:56:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Alternate-Group-Colors-based-on-Group-Var-in-Proc-Report/m-p/15776#M3405</guid>
      <dc:creator>syam_india_kochi</dc:creator>
      <dc:date>2011-06-17T09:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: Alternate Group Colors based on Group Var in Proc Report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Alternate-Group-Colors-based-on-Group-Var-in-Proc-Report/m-p/15777#M3406</link>
      <description>Sorry, I don't think I was clear before, looking for varying the row colours based on group not the column colours. &lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Sat, 18 Jun 2011 04:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Alternate-Group-Colors-based-on-Group-Var-in-Proc-Report/m-p/15777#M3406</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2011-06-18T04:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Alternate Group Colors based on Group Var in Proc Report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Alternate-Group-Colors-based-on-Group-Var-in-Proc-Report/m-p/15778#M3407</link>
      <description>Hi:&lt;BR /&gt;
  Then you can use the _ROW_ value in your CALL DEFINE statement instead of _COL_. If you only wanted the GROUP headers to be a certain color, then you could just use a format. You can still use a format to determine the colors of the rows, but the technique will be different based on whether you have 1 row per group (#1b) or multiple rows per group (#1c).&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc format;&lt;BR /&gt;
  value $prod "Men's Dress" = 'lightblue'&lt;BR /&gt;
              "Women's Dress" = 'lightpink'&lt;BR /&gt;
              "Men's Casual" = 'lightblue'&lt;BR /&gt;
              "Women's Casual" = 'lightpink'&lt;BR /&gt;
              "Sandal" = 'beige'&lt;BR /&gt;
              "Boot" = 'cxdddddd'&lt;BR /&gt;
              "Slipper" = 'yellow'&lt;BR /&gt;
              "Sport Shoe" = 'cyan';&lt;BR /&gt;
run;&lt;BR /&gt;
                          &lt;BR /&gt;
title;&lt;BR /&gt;
ods listing close;&lt;BR /&gt;
                   &lt;BR /&gt;
ods html file='c:\temp\grpcolor.html' style=sasweb;&lt;BR /&gt;
proc report data=sashelp.shoes nowd;&lt;BR /&gt;
  title '1a) coloring only the group header';&lt;BR /&gt;
  where region in ('Asia', 'Canada', 'Pacific');&lt;BR /&gt;
  column product sales,region;&lt;BR /&gt;
  define product / group &lt;BR /&gt;
         style(column)={background=$prod. foreground=black};&lt;BR /&gt;
  define region / across 'Region';&lt;BR /&gt;
  define sales/ sum ' ';&lt;BR /&gt;
run;&lt;BR /&gt;
                                  &lt;BR /&gt;
proc report data=sashelp.shoes nowd;&lt;BR /&gt;
  title '1b) coloring the entire row';&lt;BR /&gt;
  where region in ('Asia', 'Canada', 'Pacific');&lt;BR /&gt;
  column product sales,region;&lt;BR /&gt;
  define product / group ;&lt;BR /&gt;
  define region / across 'Region';&lt;BR /&gt;
  define sales/ sum ' ';&lt;BR /&gt;
  compute product;&lt;BR /&gt;
    svar = catt('style={background=',put(product,$prod.),' foreground=black}');&lt;BR /&gt;
    call define(_row_,'style',svar);&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
                                 &lt;BR /&gt;
proc report data=sashelp.shoes nowd;&lt;BR /&gt;
  title '1c) coloring multiple rows -- need to "hold" value of group var on each row';&lt;BR /&gt;
  where region in ('Asia', 'Canada', 'Pacific');&lt;BR /&gt;
  column product usecolor region sales;&lt;BR /&gt;
  define product / group ;&lt;BR /&gt;
  define usecolor / computed /* noprint */;&lt;BR /&gt;
  define region / group 'Region';&lt;BR /&gt;
  define sales/ sum 'Total';&lt;BR /&gt;
  break before product / ;&lt;BR /&gt;
  compute usecolor / character length=30;&lt;BR /&gt;
    if upcase(_break_) = 'PRODUCT' then do;&lt;BR /&gt;
       holdprod = product;&lt;BR /&gt;
    end;&lt;BR /&gt;
    usecolor = put(holdprod,$prod.);&lt;BR /&gt;
    svar = catt('style={background=',usecolor,' foreground=black}');&lt;BR /&gt;
    call define(_row_,'style',svar);&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
                            &lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Sat, 18 Jun 2011 17:26:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Alternate-Group-Colors-based-on-Group-Var-in-Proc-Report/m-p/15778#M3407</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-06-18T17:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: Alternate Group Colors based on Group Var in Proc Report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Alternate-Group-Colors-based-on-Group-Var-in-Proc-Report/m-p/15779#M3408</link>
      <description>Thanks!&lt;BR /&gt;
&lt;BR /&gt;
I wanted 'banding' so I used a combination of methods, adding some things in my datastep and then in the proc report, the code provided definitely helped in getting there!</description>
      <pubDate>Mon, 20 Jun 2011 16:40:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Alternate-Group-Colors-based-on-Group-Var-in-Proc-Report/m-p/15779#M3408</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2011-06-20T16:40:23Z</dc:date>
    </item>
  </channel>
</rss>

