<?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 Traffic lighting based on ranks in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Traffic-lighting-based-on-ranks/m-p/257514#M15413</link>
    <description>&lt;P&gt;I have a report with three columns of numbers (var1, var2 var3). I would like to highlight each column (independently) based on the within-column rank. Eg In column 1 the third of values with the highest values for var1 would be red, the third with lowest values green, and similarly for the other two columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I could do this by running proc univariate to get the p33 and p67 values for each variable, using these to create a format for each variable and then using this in the output (Proc report, tabulate or print). This sounds very messy. Is there an easier way? For example, can proc report compute blocks do calculations within columns (such as ranks?).&lt;/P&gt;</description>
    <pubDate>Fri, 18 Mar 2016 04:47:44 GMT</pubDate>
    <dc:creator>BruceBrad</dc:creator>
    <dc:date>2016-03-18T04:47:44Z</dc:date>
    <item>
      <title>Traffic lighting based on ranks</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Traffic-lighting-based-on-ranks/m-p/257514#M15413</link>
      <description>&lt;P&gt;I have a report with three columns of numbers (var1, var2 var3). I would like to highlight each column (independently) based on the within-column rank. Eg In column 1 the third of values with the highest values for var1 would be red, the third with lowest values green, and similarly for the other two columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I could do this by running proc univariate to get the p33 and p67 values for each variable, using these to create a format for each variable and then using this in the output (Proc report, tabulate or print). This sounds very messy. Is there an easier way? For example, can proc report compute blocks do calculations within columns (such as ranks?).&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2016 04:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Traffic-lighting-based-on-ranks/m-p/257514#M15413</guid>
      <dc:creator>BruceBrad</dc:creator>
      <dc:date>2016-03-18T04:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Traffic lighting based on ranks</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Traffic-lighting-based-on-ranks/m-p/257520#M15414</link>
      <description>&lt;P&gt;That is really not easy . I took some code from here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/graphicallyspeaking/2015/11/30/7180/" target="_blank"&gt;http://blogs.sas.com/content/graphicallyspeaking/2015/11/30/7180/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good Luck.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=sashelp.class out=class ties=dense;
var age weight height;
ranks r_age r_weight r_height;
run;

%let dsid=%sysfunc(open(class));
%let n=%sysfunc(attrn(&amp;amp;dsid,nlobs));
%let dsid=%sysfunc(close(&amp;amp;dsid));

%let minbin=1;
%let maxbin=&amp;amp;n;
%let BinInt=1;
data AttrMap;
  length FillColor $8 LineColor $8;
  id='Hist';
  ghigh=192; /*--High value for Green--*/
  rhigh=255; /*--High value for Red--*/

  mid=(&amp;amp;minbin + &amp;amp;maxbin) / 2;
  LineColor='CX000000';
 
  do val=&amp;amp;minbin to &amp;amp;maxbin by &amp;amp;BinInt;
    value=put(val, 5.0);
    if val &amp;lt; mid then do;
      g=ghigh; b=0; r=rhigh*(val-&amp;amp;minbin)/ (mid-&amp;amp;minbin);
    end;
    else do;
      r=rhigh; b=0; g=ghigh*(1-((val-&amp;amp;minbin) - (mid-&amp;amp;minbin))/ (mid-&amp;amp;minbin));
    end;
    fillcolor='CX' || put(r, hex2.) || put(g, hex2.) || put(b, hex2.); 
    output;
  end;
run;
data fmt;
if _n_ eq 1 then do;
 if 0 then set attrmap;
 declare hash h(dataset:'attrmap');
 h.definekey('val');
 h.definedata('fillcolor');
 h.definedone();
end;
 set class(keep=age r_age rename=(age=start r_age=k) in=ina)
     class(keep=weight r_weight  rename=(weight =start r_weight=k) in=inb)
     class(keep=height r_height rename=(height =start r_height=k) in=inc);
 h.find(key:k);
 retain type 'N';
 length fmtname $ 10;
 if ina then fmtname='age'; 
  else if inb then fmtname='weight';
   else if inc then fmtname='height';
 rename fillcolor=label;
 keep fillcolor fmtname start;
run;
proc sort data=fmt out=want_fmt nodupkey;by fmtname start;run;
proc format cntlin=want_fmt ;
run;

proc report data=class nowd ;
column age weight height;
define age/display style={background=age.};
define weight/display style={background=weight.};
define height/display style={background=height.};
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2358i47014583F2986EB2/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="x.png" title="x.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2016 06:47:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Traffic-lighting-based-on-ranks/m-p/257520#M15414</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-18T06:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: Traffic lighting based on ranks</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Traffic-lighting-based-on-ranks/m-p/257524#M15416</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
 set sashelp.class(drop=age);
 age+1;
 run;
proc rank data=x out=class ties=dense;
var age weight height;
ranks r_age r_weight r_height;
run;

%let dsid=%sysfunc(open(class));
%let n=%sysfunc(attrn(&amp;amp;dsid,nlobs));
%let dsid=%sysfunc(close(&amp;amp;dsid));

%let minbin=1;
%let maxbin=&amp;amp;n;
%let BinInt=1;
data AttrMap;
  length FillColor $8 LineColor $8;
  id='Hist';
  ghigh=192; /*--High value for Green--*/
  rhigh=255; /*--High value for Red--*/

  mid=(&amp;amp;minbin + &amp;amp;maxbin) / 2;
  LineColor='CX000000';
 
  do val=&amp;amp;minbin to &amp;amp;maxbin by &amp;amp;BinInt;
    value=put(val, 5.0);
    if val &amp;lt; mid then do;
      g=ghigh; b=0; r=rhigh*(val-&amp;amp;minbin)/ (mid-&amp;amp;minbin);
    end;
    else do;
      r=rhigh; b=0; g=ghigh*(1-((val-&amp;amp;minbin) - (mid-&amp;amp;minbin))/ (mid-&amp;amp;minbin));
    end;
    fillcolor='CX' || put(r, hex2.) || put(g, hex2.) || put(b, hex2.); 
    output;
  end;
run;
data fmt;
if _n_ eq 1 then do;
 if 0 then set attrmap;
 declare hash h(dataset:'attrmap');
 h.definekey('val');
 h.definedata('fillcolor');
 h.definedone();
end;
 set class(keep=age r_age rename=(age=start r_age=k) in=ina)
     class(keep=weight r_weight  rename=(weight =start r_weight=k) in=inb)
     class(keep=height r_height rename=(height =start r_height=k) in=inc);
 h.find(key:k);
 retain type 'N';
 length fmtname $ 10;
 if ina then fmtname='age'; 
  else if inb then fmtname='weight';
   else if inc then fmtname='height';
 rename fillcolor=label;
 keep fillcolor fmtname start;
run;
proc sort data=fmt out=want_fmt nodupkey;by fmtname start;run;
proc format cntlin=want_fmt ;
run;

proc report data=class nowd ;
column age weight height;
define age/display style={background=age.};
define weight/display style={background=weight.};
define height/display style={background=height.};
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2360iBD37E337014FAFDF/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="x.png" title="x.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2016 07:31:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Traffic-lighting-based-on-ranks/m-p/257524#M15416</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-18T07:31:06Z</dc:date>
    </item>
  </channel>
</rss>

